New answers tagged

0

Other parts of the code should be able to call the cleanup function regardless of it being inside or outside the {} braces, as long as it's declared before its actual call (actual, it's not about a former script line), and on the same or lower bash shell level ($BASH_SUBSHELL). (EDITED) The trap can be called if it was already declared and it has to be ...


3

This design has race condition written all over it. You can't be certain that the signals will be delivered in order, or even at all. If you're using Perl that makes it doubly uncertain. Redesign so that there's some confirmation from parent to child that the data got received. Signal delivery order and number is an unreliable thing, asking for a portable ...


2

The problem occurs because some programs do not cleanup properly when they are interrupted. The usual fix would be to use reset (you'll get less satisfactory results using stty sane): resetcontrolJ sends a newline even when your settings are messed up. Further reading: tset, reset - terminal initialization


4

Yes it should. If it does or not is up to the utility. Files and connections are usually closed when a program exits for whatever reason, however "other work" may be left half-done (temporary files may be left behind, databases may possibly be in a questionable state, data actually not written to files will be lost etc.) A program may catch the TERM signal ...


1

pkill (see pgrep) is a command-line utility initially written for use with the Solaris 7 operating system. It has since been reimplemented for Linux and some BSDs. As with the kill and killall commands, pkill is used to send signals to processes. The pkill command allows the use of extended regular expression patterns and other matching criteria. To signal ...


1

If you really want to do this, the following, executed by root, will send the STOP signal to everything: kill -STOP -1 This will screw with you system immensely though, so don't do that. Specifying -1 as the process ID (from the kill() C library spec in SUSv4): If pid is -1, sig shall be sent to all processes (excluding an unspecified set of system ...


1

kill allows the special value -1 for the PID parameter, meaning "all processes (excluding an unspecified set of system processes) for which the process has permission to send that signal", so this should be similar to what a call to killall5 would have done if given the number for the STOP signal: kill -SIGSTOP -1


0

Though this question has been answered let me put a detailed flow of events in Linux kernel. Signal User Space C Program Lets start with writing a simple signal user space C program : #include<signal.h> #include<stdio.h> /* Handler function */ void handler(int sig) { printf("Receive signal: %u\n", sig); }; int main(void) { struct ...


4

Without -h the job is removed from the table of active jobs, with -h it is not. Everything is in the manual: disown [-ar] [-h] [jobspec ...] (...) If the -h option is given, each jobspec is not removed from the table, but is marked so that SIGHUP is not sent to the job if the shell receives a SIGHUP. To see the ...



Top 50 recent answers are included