I have a program which is supposed to handle SIGINT and gracefully shut down. When I run this program from a terminal without backgrounding it I can shut it down just fine using Ctrl-C. Inspecting the logs shows that everything worked as expected.
When I open a separate terminal and call
kill -2 [pid] or
kill -s INT [pid] it does nothing. I see nothing in the logs and the program continues to run as usual until I hit Ctrl-C in the terminal I launched it from.
Are there any differences between how Ctrl-C sends the signal and how kill does?
The program in question is a Java application launched by a bash shell script which sets up some environment variables (namely
CLASSPATH) and then calls
java [main class]. Hitting Ctrl-Z and then running
ps results in the following:
$ ps -f UID PID PPID C STIME TTY TIME CMD mdeck 10251 10250 0 11:48 pts/2 00:00:00 -bash mdeck 13405 10251 0 18:12 pts/2 00:00:00 /bin/bash /usr/local/bin/myapp.sh mdeck 13509 13405 25 18:12 pts/2 00:00:03 java com.company.MyApp mdeck 13526 10251 0 18:13 pts/2 00:00:00 ps -f
The output of stty as requested by Gilles is below:
$ stty -a </dev/pts/2 speed 38400 baud; rows 40; columns 203; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; -parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8 opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke