New answers tagged

1

Pressing Ctrl+C in a terminal sends the SIGINT signal to the process running in the terminal. (More precisely, to all processes in the foreground process group; for example, if you're running foo | tail -f then the signal is sent to both foo and tail.) The conventional meaning of SIGINT (INTerrupt signal) is “abort the current task and return to an ...


3

The given trap command told the shell to intercept these signals: 1 SIGHUP 2 SIGINT 3 SIGQUIT 15 SIGTERM The "" is the command to be run if one of those signals is received. In other words, do nothing; ignore the signals completely. You can see what characters are bound to signals using stty -a, e.g., on the second line of output from stty in this ...


0

trap is a shell-builtin, the normal format is trap cmd list_of_signals. cmd is empty in your case, i.e. ignore that signal. 1 is the hangup signal, 3 is intr or Ctrl-C. See man bash Section Shell Builtin Commands for further explanation.


0

The kernel is free to coalesce standard signals if more than one is delivered whilst blocked. Real-time signals on the other hand are not similarly handicapped. From signal(7) manual page: Real-time signals are distinguished by the following: Multiple instances of real-time signals can be queued. By contrast, if multiple instances of a ...


4

As @muru commented, the problem is that your script does not handle SIGPIPE. The following changes will allow the script to terminate as intended: function signalHandler() { echo "sig: $1 received ==> exit" >&2 # <-- for i in {1..5}; do echo "cleanup $i %" >&2 # <-- sleep 1 done trap SIGINT ...


1

There was talk (back in the linux 0.x-1.x days) of adding this (because it was useful on BSD systems) but if I recall correctly there were reasons it was harder to do right on Linux than BSD at the time. Note that what you're asking about is only a small part of the feature (namely, you're talking about an stty info entry for control-T causing the kernel to ...


15

Yes, it's man 7 signal which, among other things, includes the following table: Signal Value Action Comment ────────────────────────────────────────────────────────────────────── SIGHUP 1 Term Hangup detected on controlling terminal or death of controlling process SIGINT 2 ...



Top 50 recent answers are included