{
printf(APPLET_full_usage "\n");
- exit(1);
+ exit(EXIT_FAILURE);
}
* "tar: A lone zero block at N", where N = kilobyte
* where EOF was met (not EOF block, actual EOF!),
* and tar will exit with error code 0.
- * We will mimic exit(0), although we will not mimic
+ * We will mimic exit(EXIT_SUCCESS), although we will not mimic
* the message and we don't check whether we indeed
* saw zero block directly before this. */
if (i == 0)
close(fd_pipe.wr); /* Send EOF */
close(src_fd);
}
- exit(0);
+ exit(EXIT_SUCCESS);
#else
{
char *argv[4];
/* exec gzip/bzip2 program/applet */
BB_EXECLP(zip_exec, zip_exec, "-f", NULL);
vfork_exec_errno = errno;
- _exit(1);
+ _exit(EXIT_FAILURE);
}
/* parent */
onintr(int sig ATTRIBUTE_UNUSED)
{
tcsetattr(STDERR_FILENO, TCSANOW, &old_termios);
- exit(1);
+ exit(EXIT_FAILURE);
}
int resize_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
}
}
- fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
/*
puts(*ep);
}
- fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
/*
}
}
- fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
break;
case '\\':
if (*++f == 'c')
- exit(0);
+ exit(EXIT_SUCCESS);
bb_putchar(bb_process_escape_sequence((const char **)&f));
f--;
break;
/* parent */
/* why _exit? the child may have changed the stack,
* so "return 0" may do bad things */
- _exit(0);
+ _exit(EXIT_SUCCESS);
}
/* child */
setsid(); /* detach from controlling tty */
enum {
OPTBIT_l, /* list matched file names only */
OPTBIT_n, /* print line# */
- OPTBIT_q, /* quiet - exit(0) of first match */
+ OPTBIT_q, /* quiet - exit(EXIT_SUCCESS) of first match */
OPTBIT_v, /* invert the match, to select non-matching lines */
OPTBIT_s, /* suppress errors about file open errors */
OPTBIT_c, /* count matches per file (suppresses normal output) */
* "exit immediately with zero status
* if any match is found,
* even if errors were detected" */
- exit(0);
+ exit(EXIT_SUCCESS);
}
/* if we're just printing filenames, we stop after the first match */
if (PRINT_FILES_WITH_MATCHES) {
{
fprintf(stderr, "Usage: %s [-p] [-r] [-t] -[x] [-n max_arg] [-s max_chars]\n",
applet_name);
- exit(1);
+ exit(EXIT_FAILURE);
}
int main(int argc, char **argv)
message(L_LOG | L_CONSOLE, "Can't open %s: %s",
tty_name, strerror(errno));
if (exit_on_failure)
- _exit(1);
+ _exit(EXIT_FAILURE);
if (ENABLE_DEBUG_INIT)
_exit(2);
/* NB: we don't reach this if we were called after vfork.
pid = fork();
if (pid < 0) {
message(L_LOG | L_CONSOLE, "Can't fork");
- _exit(1);
+ _exit(EXIT_FAILURE);
}
if (pid > 0) {
waitfor(pid);
/* See if stealing the controlling tty back is necessary */
if (tcgetpgrp(0) != getpid())
- _exit(0);
+ _exit(EXIT_SUCCESS);
/* Use a temporary process to steal the controlling tty. */
pid = fork();
if (pid < 0) {
message(L_LOG | L_CONSOLE, "Can't fork");
- _exit(1);
+ _exit(EXIT_FAILURE);
}
if (pid == 0) {
setsid();
ioctl(0, TIOCSCTTY, 1);
- _exit(0);
+ _exit(EXIT_SUCCESS);
}
waitfor(pid);
- _exit(0);
+ _exit(EXIT_SUCCESS);
}
/* Child - fall though to actually execute things */
static void init_reboot(unsigned long magic)
{
pid_t pid;
- /* We have to fork here, since the kernel calls do_exit(0) in
+ /* We have to fork here, since the kernel calls do_exit(EXIT_SUCCESS) in
* linux/kernel/sys.c, which can cause the machine to panic when
* the init process is killed.... */
pid = vfork();
if (pid == 0) { /* child */
reboot(magic);
- _exit(0);
+ _exit(EXIT_SUCCESS);
}
waitfor(pid);
}
kill(pid, SIGKILL);
}
}
- _exit(0);
+ _exit(EXIT_SUCCESS);
}
#endif
}
/* SELinux in enforcing mode but load_policy failed */
message(L_CONSOLE, "Cannot load SELinux Policy. "
"Machine is in enforcing mode. Halting now.");
- exit(1);
+ exit(EXIT_FAILURE);
}
}
#endif /* CONFIG_SELINUX */
signal(sig, SIG_DFL);
sig_unblock(sig);
raise(sig);
- _exit(1); /* Should not reach it */
+ _exit(EXIT_FAILURE); /* Should not reach it */
}
void signal_SA_RESTART_empty_mask(int sig, void (*handler)(int))
if (pid < 0) /* wtf? */
bb_perror_msg_and_die("vfork");
if (pid) /* parent */
- exit(0);
+ exit(EXIT_SUCCESS);
/* child - re-exec ourself */
re_exec(argv);
}
if (pid < 0) /* wtf? */
bb_perror_msg_and_die("fork");
if (pid) /* parent */
- exit(0);
+ exit(EXIT_SUCCESS);
/* child */
}
#define forkexit_or_rexec(argv) forkexit_or_rexec()
/* Do not report trivial EINTR/EIO errors. */
if (read(0, &c, 1) < 1) {
if (errno == EINTR || errno == EIO)
- exit(0);
+ exit(EXIT_SUCCESS);
bb_perror_msg_and_die("%s: read", op->tty);
}
}
break;
case CTL('D'):
- exit(0);
+ exit(EXIT_SUCCESS);
default:
if (!isascii(ascval) || !isprint(ascval)) {
/* ignore garbage characters */
fclose(fp);
} else
puts("\r\nSystem closed for routine maintenance\r");
- exit(1);
+ exit(EXIT_FAILURE);
}
#else
static ALWAYS_INLINE void die_if_nologin(void) {}
/* skip whitespace */
do {
c = getchar();
- if (c == EOF) exit(1);
+ if (c == EOF) exit(EXIT_FAILURE);
if (c == '\n') {
- if (!--cntdown) exit(1);
+ if (!--cntdown) exit(EXIT_FAILURE);
goto prompt;
}
} while (isspace(c));
*buf++ = c;
if (!fgets(buf, size_buf-2, stdin))
- exit(1);
+ exit(EXIT_FAILURE);
if (!strchr(buf, '\n'))
- exit(1);
+ exit(EXIT_FAILURE);
while (isgraph(*buf)) buf++;
*buf = '\0';
}
ioctl(STDIN_FILENO, VT_SETMODE, &ovtm);
tcsetattr(STDIN_FILENO, TCSANOW, &oterm);
- fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
if (mail_filename) {
fdprintf(1, "Exec failed: %s -c %s\n", prog, arg);
}
- _exit(0);
+ _exit(EXIT_SUCCESS);
}
line->cl_Pid = pid;
execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", line->cl_Shell, NULL);
crondlog(ERR20 "can't exec, user %s cmd %s %s %s", user,
DEFAULT_SHELL, "-c", line->cl_Shell);
- _exit(0);
+ _exit(EXIT_SUCCESS);
}
if (pid < 0) {
/* FORK FAILED */
#else
#define info_logger(p, fmt, args...)
#define msg_logger(p, fmt, args...)
-#define msg_logger_and_die(p, fmt, args...) exit(1)
+#define msg_logger_and_die(p, fmt, args...) exit(EXIT_FAILURE)
#define error_logger(p, fmt, args...)
-#define error_logger_and_die(p, fmt, args...) exit(1)
+#define error_logger_and_die(p, fmt, args...) exit(EXIT_FAILURE)
#endif
static void safe_memcpy(char *dest, const char *src, int len)
dir_operation(SERVICE, mount_point, 0, NULL);
if (ENABLE_DEVFSD_FG_NP && no_polling)
- exit(0);
+ exit(EXIT_SUCCESS);
if (ENABLE_DEVFSD_VERBOSE || ENABLE_DEBUG)
logmode = LOGMODE_BOTH;
change_file(-1);
break;
case 'q':
- less_exit(0);
+ less_exit(EXIT_SUCCESS);
break;
case 'x':
change_file(0);
buffer_line(cur_fline);
break;
case 'q': case 'Q':
- less_exit(0);
+ less_exit(EXIT_SUCCESS);
break;
#if ENABLE_FEATURE_LESS_MARKS
case 'm':
return WTERMSIG(res.waitstatus);
if (WIFEXITED(res.waitstatus))
return WEXITSTATUS(res.waitstatus);
- fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
write(3, &V, 1); /* Magic, see watchdog-api.txt in kernel */
if (ENABLE_FEATURE_CLEAN_UP)
close(3);
- exit(0);
+ exit(EXIT_SUCCESS);
}
int watchdog_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
close(sep->se_fd);
}
remove_pidfile(_PATH_INETDPID);
- exit(0);
+ exit(EXIT_SUCCESS);
}
int inetd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
else
sep->se_builtin->bi_dgram_fn(ctrl, sep);
if (pid) /* we did vfork */
- _exit(1);
+ _exit(EXIT_FAILURE);
maybe_close(accepted_fd);
continue; /* -> check next fd in fd set */
}
/* eat packet in udp case */
if (sep->se_socktype != SOCK_STREAM)
recv(0, line, LINE_SIZE, MSG_DONTWAIT);
- _exit(1);
+ _exit(EXIT_FAILURE);
} /* for (sep = servtab...) */
} /* for (;;) */
}
close(STDERR_FILENO);
xopen("/dev/null", O_WRONLY);
BB_EXECVP("cat", (char**)cat_args);
- /* on failure we return to main, which does exit(1) */
+ /* on failure we return to main, which does exit(EXIT_FAILURE) */
#endif
}
static void echo_dg(int s, servtab_t *sep)
/* no error messages please... */
xdup2(STDOUT_FILENO, STDERR_FILENO);
BB_EXECVP("cat", (char**)cat_args);
- /* on failure we return to main, which does exit(1) */
+ /* on failure we return to main, which does exit(EXIT_FAILURE) */
#endif
}
/* ARGSUSED */
struct ip_tunnel_parm old_p;
memset(&old_p, 0, sizeof(old_p));
if (do_get_ioctl(*argv, &old_p))
- exit(1);
+ exit(EXIT_FAILURE);
*p = old_p;
}
}
nread = safe_read(fd, iobuf, sizeof(iobuf));
if (fd == cfd) {
if (nread < 1)
- exit(0);
+ exit(EXIT_SUCCESS);
ofd = STDOUT_FILENO;
} else {
if (nread<1) {
dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa);
ping(lsa);
- print_stats_and_exit(0);
+ print_stats_and_exit(EXIT_SUCCESS);
/*return EXIT_SUCCESS;*/
}
#endif /* FEATURE_FANCY_PING */
/* Set encapsulation (SLIP, CSLIP, etc) */
if (ioctl_or_warn(handle, SIOCSIFENCAP, &encap) < 0) {
bad:
- restore_state_and_exit(1);
+ restore_state_and_exit(EXIT_FAILURE);
}
}
static void sig_handler(int signo ATTRIBUTE_UNUSED)
{
- restore_state_and_exit(0);
+ restore_state_and_exit(EXIT_SUCCESS);
}
int slattach_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
system(extcmd);
/* Restore states and exit */
- restore_state_and_exit(0);
+ restore_state_and_exit(EXIT_SUCCESS);
}
" e exit telnet\r\n");
if (read(0, &b, 1) <= 0)
- doexit(1);
+ doexit(EXIT_FAILURE);
switch (b) {
case 'l':
rawmode();
break;
case 'e':
- doexit(0);
+ doexit(EXIT_SUCCESS);
}
write_str(1, "continuing...\r\n");
{
len = read(0, G.buf, DATABUFSIZE);
if (len <= 0)
- doexit(0);
+ doexit(EXIT_SUCCESS);
TRACE(0, ("Read con: %d\n", len));
handlenetoutput(len);
}
len = read(G.netfd, G.buf, DATABUFSIZE);
if (len <= 0) {
write_str(1, "Connection closed by foreign host\r\n");
- doexit(1);
+ doexit(EXIT_FAILURE);
}
TRACE(0, ("Read netfd (%d): %d\n", G.netfd, len));
handlenetinput(len);
BB_EXECVP(loginpath, (char **)login_argv);
/* _exit is safer with vfork, and we shouldn't send message
* to remote clients anyway */
- _exit(1); /*bb_perror_msg_and_die("execv %s", loginpath);*/
+ _exit(EXIT_FAILURE); /*bb_perror_msg_and_die("execv %s", loginpath);*/
}
/* Must match getopt32 string */
struct tsession *t = sessions;
if (option_mask32 & OPT_INETD)
- exit(0);
+ exit(EXIT_SUCCESS);
/* Unlink this telnet session from the session list */
if (t == ts)
#else /* !FEATURE_TELNETD_STANDALONE */
-/* Used in main() only, thus "return 0" actually is exit(0). */
+/* Used in main() only, thus "return 0" actually is exit(EXIT_SUCCESS). */
#define free_session(ts) return 0
#endif
static void sig_catcher(int sig ATTRIBUTE_UNUSED)
{
reset_term();
- exit(1);
+ exit(EXIT_FAILURE);
}
#endif /* FEATURE_USE_TERMIOS */
if (svd[0].want == W_EXIT && svd[0].state == S_DOWN) {
if (svd[1].pid == 0)
- _exit(0);
+ _exit(EXIT_SUCCESS);
if (svd[1].want != W_EXIT) {
svd[1].want = W_EXIT;
/* stopservice(&svd[1]); */
switch (exitsoon) {
case 1:
- _exit(0);
+ _exit(EXIT_SUCCESS);
case 2:
for (i = 0; i < svnum; i++)
if (sv[i].pid)
optind++;
if (nerr)
- exit(1);
+ exit(EXIT_FAILURE);
}
if (input_filename) {
full_write(pip[1], redir->nhere.doc->narg.text, len);
else
expandhere(redir->nhere.doc, pip[1]);
- _exit(0);
+ _exit(EXIT_SUCCESS);
}
out:
close(pip[1]);
{
for (envp = environ; *envp; envp++)
puts (*envp);
- exit (0);
+ exit(EXIT_SUCCESS);
}
/* printenv varname */
if (*eval == '=')
{
puts (eval + 1);
- exit (0);
+ exit(EXIT_SUCCESS);
}
}
}
- exit (1);
+ exit(EXIT_FAILURE);
}
strprint(argv[i]);
printf(">\n");
}
- exit(0);
+ exit(EXIT_SUCCESS);
}
void
}
putchar('\n');
- exit(0);
+ exit(EXIT_SUCCESS);
}
run_applet_and_exit(cmd->argv[0],cmd->argc,cmd->argv);
execvp(cmd->argv[0],cmd->argv);
printf("No %s",cmd->argv[0]);
- exit(1);
+ exit(EXIT_FAILURE);
} else waitpid(pid, &status, 0);
}
debug_printf_exec("execing '%s'\n", argv[0]);
execvp(argv[0], argv);
bb_perror_msg("cannot exec '%s'", argv[0]);
- _exit(1);
+ _exit(EXIT_FAILURE);
}
/* Called after [v]fork() in run_pipe()
if (t->op_type == TPAREN)
_exit(execute(t->left, NOPIPE, NOPIPE, /* no_fork: */ 1));
if (wp[0] == NULL)
- _exit(0);
+ _exit(EXIT_SUCCESS);
cp = rexecve(wp[0], wp, makenv(0, NULL));
prs(wp[0]);
prs(argument_list[0]);
prs(": ");
err(cp);
- _exit(1);
+ _exit(EXIT_FAILURE);
}
while (size == 0 || position >= size) {
size = read_line_input(current_prompt, filechar_cmdbuf, BUFSIZ, line_input_state);
if (size < 0) /* Error/EOF */
- exit(0);
+ exit(EXIT_SUCCESS);
position = 0;
/* if Ctrl-C, size == 0 and loop will repeat */
}
name = *++argv;
if (newfile(name))
- exit(1); /* Exit on error */
+ exit(EXIT_FAILURE); /* Exit on error */
}
}
{
signal(SIGINT, SIG_IGN);
shmdt(shbuf);
- exit(0);
+ exit(EXIT_SUCCESS);
}
int logread_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
sz = read_line_input(prompt, line_buffer, sizeof(line_buffer), NULL);
if (sz <= 0)
- exit(0); /* Ctrl-D or Ctrl-C */
+ exit(EXIT_SUCCESS); /* Ctrl-D or Ctrl-C */
if (line_buffer[sz-1] == '\n')
line_buffer[--sz] = '\0';
if (ENABLE_FEATURE_CLEAN_UP)
close_dev_fd();
bb_putchar('\n');
- exit(0);
+ exit(EXIT_SUCCESS);
case 'r':
return;
case 's':
what = SEM;
if (remove_ids(what, argc-2, &argv[2]))
- fflush_stdout_and_exit(1);
+ fflush_stdout_and_exit(EXIT_FAILURE);
printf("resource(s) deleted\n");
return 0;
}
if (flags & flag_print) {
if (flags & flag_shm) {
print_shm(id);
- fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
if (flags & flag_sem) {
print_sem(id);
- fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
if (flags & flag_msg) {
print_msg(id);
- fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
bb_show_usage();
}
do_msg();
bb_putchar('\n');
}
- fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}