From 3f3aa2a57dc648ade9083f3b3ad83cce8206b912 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Mon, 9 Apr 2007 21:35:07 +0000 Subject: make xfunctions optionally longjump instead of exit. use it for making NOFORK more practical. touch: make it a NOFORK applet --- coreutils/cmp.c | 2 +- coreutils/touch.c | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'coreutils') 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 -#include -#include -#include -#include -#include -#include #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; } -- cgit v1.2.3