Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k
Tweeted twitter.com/#!/StackUnix/status/398343167202045952
Source Link
Cory Klein
  • 19.4k
  • 28
  • 84
  • 96

Default exit code when process is terminated?

When a process is killed with a handle-able signal like SIGINT or SIGTERM but it does not handle the signal, what will be the exit code of the process?

What about for unhandle-able signals like SIGKILL?

From what I can tell, killing a process with SIGINT likely results in exit code 130, but would that vary by kernel or shell implementation?

$ cat myScript
#!/bin/bash
sleep 5
$ ./myScript
<ctrl-c here>
$ echo $?
130

I'm not sure how I would test the other signals...

$ ./myScript &
$ killall myScript
$ echo $?
0  # duh, that's the exit code of killall
$ killall -9 myScript
$ echo $?
0  # same problem