diff options
author | Rob Landley <rob@landley.net> | 2016-03-29 03:59:20 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2016-03-29 03:59:20 -0500 |
commit | 0e05569e308f927cd84882f7463739681bf1a33b (patch) | |
tree | 306bb0f70500028948256fe92d0e1db5f0968f36 /lib | |
parent | e223cca4f66bf2e201b21869304dc63befbbf9be (diff) | |
download | toybox-0e05569e308f927cd84882f7463739681bf1a33b.tar.gz |
Fix exit code of things like sed -i that use tempfile_handler().
(The sigatexit() handler list code now calls the handlers on the normal
exit path, so _exit(1) from the handler is wrong; exit_signal() modifies
toys.exitval if necessary.)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lib.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -618,10 +618,9 @@ int wfchmodat(int fd, char *name, mode_t mode) } static char *tempfile2zap; -static void tempfile_handler(int i) +static void tempfile_handler(void) { if (1 < (long)tempfile2zap) unlink(tempfile2zap); - _exit(1); } // Open a temporary file to copy an existing file into. @@ -759,12 +758,13 @@ void generic_signal(int sig) void exit_signal(int sig) { - toys.exitval = sig|128; + if (sig) toys.exitval = sig|128; xexit(); } // Install the same handler on every signal that defaults to killing the -// process, and +// process, calling the handler on the way out. Calling multiple times +// adds the handlers to a list, to be called in order. void sigatexit(void *handler) { struct arg_list *al = xmalloc(sizeof(struct arg_list)); |