I have a architecture with one parent that spawns a child as follow :
this.process = child.spawn(this.cmd, this.args);
this.process.on('exit', (code: number, signal: string) => {
this.exitCode = code;
console.log(`exit code: ${code}`);
});
there is no particular option because i want to keep a link with the child. So, when i press Ctr-C to kill the parent, it catches SIGINT
to (1) end the child, (2) exit properly. But SIGINT
is also propagated to the child, so the parent cannot end it gracefully. So, is there a way to do so ? maybe by preventing SIGINT
to be propagated to the child ? or telling the child to ignore the signal ?
i know that something is possible by adding option detached: true
and stdio: 'ignore'
when spawning, but i don't want to do that because if the parent dies, i end up with zombies process. Whereas keeping the links ensure that the child is killed if the parent dies unexpectedly. Finally, i want to avoid catching SIGINT
in the child as i want to keep it dumb.
EDIT: the parent already have a process.on('SIGINT', () => { ... }
and the child is in python.