On 8/20/15 4:36 PM, J. Lewis Muir wrote: > Hello, NetBSD Users! > > I can't get /bin/sh to trap the SIGHUP signal on amd64 NetBSD > 6.1_STABLE. Does anyone know why? > > Here's a test program exhibiting the behavior: > > === test-program === > #!/bin/sh > > trap 'echo SIGHUP; exit 1' 1 > > sleep 3600 & > wait > ====================
I have now tested trapping SIGINT, SIGQUIT, SIGPIPE, and SIGTERM too, and of those, only SIGINT causes the program to exit. Here's the new test program I used: === test-program2 === #!/bin/sh trap 'echo SIGHUP; exit 1' 1 trap 'echo SIGINT; exit 1' 2 trap 'echo SIGQUIT; exit 1' 3 trap 'echo SIGPIPE; exit 1' 13 trap 'echo SIGTERM; exit 1' 15 sleep 3600 & wait ===================== As I said, nothing happens when I send the signals, with the exception of SIGINT which causes the program to exit. Interestingly, when I interrupt the program by pressing Ctrl-C in the terminal, I get two lines of output: one for the signal I sent that seemed to do nothing and the other for the SIGINT sent by pressing Ctrl-C. Here's the output for the five cases in order (SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGTERM) including where I pressed Ctrl-C for each case except SIGINT: === test-program2 terminal === $ ./test-program2 ^CSIGHUP SIGINT $ ./test-program2 SIGINT $ ./test-program2 ^CSIGINT SIGQUIT $ ./test-program2 ^CSIGINT SIGPIPE $ ./test-program2 ^CSIGINT SIGTERM ============================== I'm worried I'm rediscovering some basic behavior that is a surprise to me but not to many others. Is this the right behavior for waiting on jobs? Why does a trap for SIGINT work while waiting in the wait command but a trap for the other signals does not? Thank you! Lewis