Skip to content

Commit

Permalink
stress-ng: don't kill entire group or pid 1 (init)
Browse files Browse the repository at this point in the history
Ensure invalid PIDs are not killed. This can occur if we're spawning
lots of stressors and SIGINT is sent before all the stressors are
stared, leaving uninitialized -1 pids being killed, causing the entire
group session to be killed. Fix this.

Signed-off-by: Colin Ian King <[email protected]>
  • Loading branch information
ColinIanKing committed Dec 20, 2023
1 parent 5cba406 commit 41e0d1a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion stress-ng.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,8 @@ static void stress_kill_stressors(const int sig, const bool force_sigkill)
stress_stats_t *const stats = ss->stats[i];
const pid_t pid = stats->pid;

if (pid && !stats->signalled) {
/* Don't kill -1 (group), or init processes! */
if ((pid > 1) && !stats->signalled) {
(void)shim_kill(pid, signum);
stats->signalled = true;
}
Expand Down

0 comments on commit 41e0d1a

Please sign in to comment.