Tag Info

New answers tagged

0

It seems to be the right place to mention that SVr4 introduced waitid() in 1898, but no important program seems to use it so far. waitid() allows to retrieve the full 32 bits from the exit() code. About 2 months ago, I rewrote the wait/job control part of the Bourne Shell to use waitid() instead of waitpid(). This was done in order to remove the limitation ...


7

When you press Ctrl+Z in a terminal, this causes the foreground process group to receive the signal SIGTSTP (assuming the terminal is in cooked mode and the default key bindings are in place). If the process hasn't set a signal handler for SIGTSTP, this causes the process to be suspended (and even if the process has set a signal handler, it usually only does ...


6

Having a global keybind to disown the foreground process is impossible: Keystrokes are received by the foreground process, not by the shell. You need to first suspend it with Ctrl+z if you want to disown it. However, turns out there's a zsh option to speed up disowning then continuing: With setopt AUTO_CONTINUE, disown will automatically also send SIGCONT. ...


5

vi-vi-vi is of the devil. You must kill it with fire. Or SIGKILL: kill -KILL %1 The builtin kills are kind enough to send SIGCONT to suspended processes so that you don't have to do it yourself, but that won't help if the process blocks the signal you're sending or if handling the signal causes the processes to become suspended again (if a background ...


4

vim is installing signal handlers (and probably also setting sigprocmask(2)) to ignore common signals so that any files being edited are not lost due to a stray control+c or random kill signal. A simpler program is readily killed: % cat busyloop.c int main(void) { for (;;) { ; } return 0; } % make busyloop cc busyloop.c -o busyloop % ./busyloop ^Z zsh: ...


5

Although you could disable Ctrl-c and Ctrl-z by disabling those terminal settings or setting the terminal to raw more or other solutions, you are usually much better off leaving them enabled and reacting to the resulting signals instead. You can install handlers for the signals and let the handlers do nothing. The way to install handlers depends on the ...


0

The solution evolved into http://www.gnu.org/software/parallel/parallel_design.html#Remote-Ctrl-C-and-standard-error-stderr $SIG{CHLD} = sub { $done = 1; }; $pid = fork; unless($pid) { # Make own process group to be able to kill HUP it later setpgrp; exec $ENV{SHELL}, "-c", ($bashfunc."@ARGV"); die "exec: $!\n"; } do { # Parent is not ...



Top 50 recent answers are included