diff options
author | Arkadiusz Hiler <arkadiusz.hiler@intel.com> | 2020-06-03 15:47:11 +0300 |
---|---|---|
committer | Arkadiusz Hiler <arkadiusz.hiler@intel.com> | 2020-06-04 12:54:47 +0300 |
commit | 1af067a15b3000c559c93d6a8dd5a5079c4f8af0 (patch) | |
tree | 603d180bdb131e922023c15913798cad896c997a /lib/tests | |
parent | a9b6c4c74bfddf7d3d2da3be08804fe315945cea (diff) |
lib/igt_core: Don't kill the world after a failed fork
If we fail to fork (e.g. due to restrictive limits) -1 gets written as
PID of our child and we assert out.
The cleanup that happens afterwards tries to kill all our children,
which ends up in kill(-1, SIGKILL) which is not good.
This patch makes sure of two things:
* -1 doesn't get written down as our child
* when we are killing children we make sure that pid > 0
Reported-by: Fei Yang <fei.yang@intel.com>
Cc: Michael Hebenstreit <michael.hebenstreit@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Tested-by: Michael Hebenstreit <michael.hebenstreit@intel.com>
Reviewed-by: Petri Latvala <petri.latvala@intel.com>
Diffstat (limited to 'lib/tests')
-rw-r--r-- | lib/tests/igt_fork.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c index 4fd0e0c8..84492b2d 100644 --- a/lib/tests/igt_fork.c +++ b/lib/tests/igt_fork.c @@ -123,8 +123,10 @@ static void subtest_leak(void) } /* We expect the exit_subtest to cleanup after the igt_fork */ - for (int i = 0; i < num_children; i++) - assert(kill(children[i], 0) == -1 && errno == ESRCH); + for (int i = 0; i < num_children; i++) { + if (children[i] > 0) + assert(kill(children[i], 0) == -1 && errno == ESRCH); + } munmap(children, 4096); |