make xfunctions optionally longjump instead of exit.

use it for making NOFORK more practical.
touch: make it a NOFORK applet
This commit is contained in:
Denis Vlasenko
2007-04-09 21:35:07 +00:00
parent cd7001f705
commit 3f3aa2a57d
10 changed files with 39 additions and 24 deletions

View File

@ -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";

View File

@ -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;
}