diff options
author | Rob Landley <rob@landley.net> | 2014-05-21 07:24:16 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2014-05-21 07:24:16 -0500 |
commit | 1bc522424f6bb21842366ccd11953136436b684b (patch) | |
tree | a65e3b53e4b39c9b7700110d388346beae8c248f /lib | |
parent | 9b4158c09cdb766369c45dd2dbc44556d0892694 (diff) | |
download | toybox-1bc522424f6bb21842366ccd11953136436b684b.tar.gz |
Add generic_signal() handler, which sets toys.signal and writes byte to toys.signalfd if set.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lib.c | 12 | ||||
-rw-r--r-- | lib/lib.h | 1 |
2 files changed, 13 insertions, 0 deletions
@@ -614,12 +614,24 @@ static struct signame signames[] = { // not in posix: SIGNIFY(STKFLT), SIGNIFY(WINCH), SIGNIFY(IO), SIGNIFY(PWR) // obsolete: SIGNIFY(PROF) SIGNIFY(POLL) +// Handler that sets toys.signal, and writes to toys.signalfd if set +void generic_signal(int sig) +{ + if (toys.signalfd) { + char c = sig; + + writeall(toys.signalfd, &c, 1); + } + toys.signal = sig; +} + // Install the same handler on every signal that defaults to killing the process void sigatexit(void *handler) { int i; for (i=0; signames[i].num != SIGCHLD; i++) signal(signames[i].num, handler); } + // Convert name to signal number. If name == NULL print names. int sig_to_num(char *pidstr) { @@ -174,6 +174,7 @@ struct mtab_list *xgetmountlist(char *path); // signal +void generic_signal(int signal); void sigatexit(void *handler); int sig_to_num(char *pidstr); char *num_to_sig(int sig); |