I need to send SIGINT
to terminate a process gracefully but I can't.
This is a sample, because the environment in which the execution occurs is 'unknown' (a bash script in travis.com)
I managed to get (simulate) the same behaviour, by launching a process like this (command &) &
vagrant@host:~$ (sleep 40 &) &
[1] 8473
vagrant@host:~$ ps -o pid,pgid,args
PID PGID COMMAND
2787 2787 -bash
8474 8473 sleep 40
8490 8490 ps -o pid,pgid,args
[1]+ Done ( sleep 40 & )
vagrant@host:~$ kill -INT 8474 ##### here I send SIGINT to the process
vagrant@host:~$ kill -INT -8473 ##### here I send SIGINT to the process group
vagrant@host:~$ ps -o pid,pgid,args
PID PGID COMMAND
2787 2787 -bash
8474 8473 sleep 40
8559 8559 ps -o pid,pgid,args
I googled and read a lot about signals and groups and I can't understand what is happening here. Is the signal being ignored at some point? What is happening? How can I send SIGINT
to that sleep
process?
EDIT: if SIGTERM
is used, the process is killed (maybe the parent subshell is killed?)
trap - INT
to reset the handler to its default. – Stéphane Chazelas Jan 19 '16 at 16:00