Cleanup all zombie processes

Prevents process table exhaustion
This commit is contained in:
Thomas Hobson 2022-04-27 02:51:10 +12:00 committed by GitHub
parent 37e83c9813
commit 0ab66f4f5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -337,13 +337,19 @@ class Job {
const [_1, state, user_friendly] = state_line.split(/\s+/); const [_1, state, user_friendly] = state_line.split(/\s+/);
if (state == 'Z') const proc_id_int = parse_int(proc_id);
// Zombie process, just needs to be waited
if (state == 'Z'){
// Zombie process, just needs to be waited, regardless of the user id
if(!to_wait.includes(proc_id_int))
to_wait.push(proc_id_int);
return -1; return -1;
}
// We should kill in all other state (Sleep, Stopped & Running) // We should kill in all other state (Sleep, Stopped & Running)
if (ruid == this.uid || euid == this.uid) if (ruid == this.uid || euid == this.uid)
return parse_int(proc_id); return proc_id_int;
} catch { } catch {
return -1; return -1;
} }