mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-19 13:01:15 -03:00
Teach keepalives to exit when their parent dies
keepalive processes are typically killed by the main shell process. However if the main shell exits the keepalive may linger. In WSL keepalives are used more often, and the lingering keepalives are both leaks and prevent the tests from finishing. Have keepalives poll for their parent process ID and exit when it changes, so they can clean themselves up. The polling frequency can be low.
This commit is contained in:
@@ -586,12 +586,13 @@ void exec_job(parser_t &parser, job_t *j) {
|
||||
|
||||
if (needs_keepalive) {
|
||||
// Call fork. No need to wait for threads since our use is confined and simple.
|
||||
pid_t parent_pid = getpid();
|
||||
keepalive.pid = execute_fork(false);
|
||||
if (keepalive.pid == 0) {
|
||||
// Child
|
||||
keepalive.pid = getpid();
|
||||
child_set_group(j, &keepalive);
|
||||
pause();
|
||||
run_as_keepalive(parent_pid);
|
||||
exit_without_destructors(0);
|
||||
} else {
|
||||
// Parent
|
||||
|
||||
Reference in New Issue
Block a user