Tag Info

New answers tagged

1

You can use gdb to do this: gdb --batch -ex 'handle all print' -ex 'handle all nostop' -ex 'handle all pass' -ex 'run' cat will run cat under GDB and print all signals, pass them to the program and not stop execution. Doing this for a background program is harder, as GDB will try and go into the background instead. You might be better off starting it with ...


5

First, this isn't specific to bash. ATT ksh, dash and zsh behave the same way: they ignore SIGTERM and SIGQUIT during command line edition; as for mksh, it also doesn't quit but treats them like SIGINT. Both the ksh manual and the bash manual justify ignoring SIGTERM in these terms: so that kill 0 does not kill an interactive shell kill 0 kills all ...


4

This might answer your question: When Bash is interactive, in the absence of any traps, it ignores SIGTERM (so that ‘kill 0’ does not kill an interactive shell), and SIGINT is caught and handled (so that the wait builtin is interruptible). When Bash receives a SIGINT, it breaks out of any executing loops. In all cases, Bash ignores SIGQUIT. If ...


4

The continue keyword doesn't mean whatever you think it means. It means continue to the next iteration of a loop. It makes no sense outside of a loop. I think you're looking for trap ' ' INT Since you don't want to do anything upon reception of the signal (beyond killing the foreground job), put no code in the trap. You need a non-empty string, because ...


0

The error arise due to trap 'continue' SIGINT. From help trap: ARG is a command to be read and executed when the shell receives the signal(s) SIGNAL_SPEC So your script try to do continue command when recive SIGINT call but the continue is used in loops only.


0

A simple enough solution: Have process A exec a second process A first (call it A'). Then let A block forever. A' can start D, and D can restart A', and A sticks around the whole time as the parent.


3

I'm assuming you're trying to pass the value of the signal you've caught to the action you want to take. Try something like this: # 1 SIGHUP # 2 SIGINT # 3 SIGQUIT # 6 SIGABRT # 9 SIGKILL # 14 SIGALRM # 15 SIGTERM for sig in 1 2 3 6 9 14 15; do trap 'echo "caught signal '$sig'..."' $sig done


8



Top 50 recent answers are included