diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-10 01:35:07 +0400 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-10 01:35:07 +0400 |
commit | 3f3aa2a57dc648ade9083f3b3ad83cce8206b912 (patch) | |
tree | d5c648f583bb2edef25f05c2bed303df3d1a61f6 /coreutils | |
parent | cd7001f7055c3fc2d6298ab9e3befe91e951c652 (diff) |
make xfunctions optionally longjump instead of exit.
use it for making NOFORK more practical.
touch: make it a NOFORK applet
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/cmp.c | 2 | ||||
-rw-r--r-- | coreutils/touch.c | 13 |
2 files changed, 5 insertions, 10 deletions
diff --git a/coreutils/cmp.c b/coreutils/cmp.c index cff118279..c70f8822d 100644 --- a/coreutils/cmp.c +++ b/coreutils/cmp.c @@ -30,7 +30,7 @@ static FILE *cmp_xfopen_input(const char * const filename) fp = fopen_or_warn_stdin(filename); if (fp) return fp; - exit(xfunc_error_retval); /* We already output an error message. */ + sleep_and_die(); /* We already output an error message. */ } static const char fmt_eof[] = "cmp: EOF on %s\n"; diff --git a/coreutils/touch.c b/coreutils/touch.c index ae4e689f1..5f81b2380 100644 --- a/coreutils/touch.c +++ b/coreutils/touch.c @@ -17,21 +17,16 @@ * Also, exiting on a failure was a bug. All args should be processed. */ -#include <stdio.h> -#include <sys/types.h> -#include <fcntl.h> -#include <utime.h> -#include <errno.h> -#include <unistd.h> -#include <stdlib.h> #include "busybox.h" +/* This is a NOFORK applet. Be very careful! */ + int touch_main(int argc, char **argv); int touch_main(int argc, char **argv) { int fd; int status = EXIT_SUCCESS; - bool flags = (getopt32(argc, argv, "c") & 1); + int flags = getopt32(argc, argv, "c"); argv += optind; @@ -41,7 +36,7 @@ int touch_main(int argc, char **argv) do { if (utime(*argv, NULL)) { - if (errno == ENOENT) { /* no such file*/ + if (errno == ENOENT) { /* no such file */ if (flags) { /* Creation is disabled, so ignore. */ continue; } |