From: Sami Kerola Date: Sat, 1 Dec 2012 22:43:55 +0000 (+0000) Subject: anacron: remove numeric exit and file descriptor values X-Git-Tag: cronie1.4.11~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ea3c5f99beb1bc1786d8b0b5e617229dd0287614;p=cronie anacron: remove numeric exit and file descriptor values Use symbolic values from standard header instead. Signed-off-by: Sami Kerola --- diff --git a/anacron/main.c b/anacron/main.c index 2c55716..66928cc 100644 --- a/anacron/main.c +++ b/anacron/main.c @@ -138,10 +138,10 @@ parse_opts(int argc, char *argv[]) break; case 'V': print_version(); - exit(0); + exit(EXIT_SUCCESS); case 'h': print_usage(); - exit(0); + exit(EXIT_SUCCESS); case '?': fprintf(stderr, "%s: invalid option: %c\n", program_name, optopt); @@ -217,7 +217,7 @@ go_background() if (pid != 0) { /* parent */ - exit(0); + exit(EXIT_SUCCESS); } else { @@ -318,7 +318,7 @@ orderly_termination() got_sigusr1 = 0; wait_children(); explain("Exited"); - exit(0); + exit(EXIT_SUCCESS); } static void @@ -475,7 +475,7 @@ main(int argc, char *argv[]) if (sigprocmask(0, NULL, &old_sigmask)) die_e("sigset error"); if (fclose(stdin)) die_e("Can't close stdin"); - xopen(0, "/dev/null", O_RDONLY); + xopen(STDIN_FILENO, "/dev/null", O_RDONLY); if (!no_daemon && !testing_only) go_background(); @@ -489,15 +489,15 @@ main(int argc, char *argv[]) if (testing_only) { - if (complaints) exit (1); + if (complaints) exit (EXIT_FAILURE); - exit (0); + exit (EXIT_SUCCESS); } if (update_only) { fake_jobs(); - exit(0); + exit(EXIT_SUCCESS); } explain_intentions(); @@ -511,5 +511,5 @@ main(int argc, char *argv[]) } wait_children(); explain("Normal exit (%d job%s run)", njobs, njobs == 1 ? "" : "s"); - exit(0); + exit(EXIT_SUCCESS); } diff --git a/anacron/runjob.c b/anacron/runjob.c index 2a44299..9656254 100644 --- a/anacron/runjob.c +++ b/anacron/runjob.c @@ -180,17 +180,17 @@ launch_mailer(job_rec *jr) /* child */ in_background = 1; /* set stdin to the job's output */ - xclose(0); - if (dup2(jr->input_fd, 0) != 0) die_e("Can't dup2()"); - if (lseek(0, 0, SEEK_SET) != 0) die_e("Can't lseek()"); + xclose(STDIN_FILENO); + if (dup2(jr->input_fd, STDIN_FILENO) != 0) die_e("Can't dup2()"); + if (lseek(STDIN_FILENO, 0, SEEK_SET) != 0) die_e("Can't lseek()"); umask(old_umask); if (sigprocmask(SIG_SETMASK, &old_sigmask, NULL)) die_e("sigprocmask error"); xcloselog(); /* Ensure stdout/stderr are sane before exec-ing sendmail */ - xclose(1); xopen(1, "/dev/null", O_WRONLY); - xclose(2); xopen(2, "/dev/null", O_WRONLY); + xclose(STDOUT_FILENO); xopen(STDOUT_FILENO, "/dev/null", O_WRONLY); + xclose(STDERR_FILENO); xopen(STDERR_FILENO, "/dev/null", O_WRONLY); xclose(jr->output_fd); /* Ensure stdin is not appendable ... ? */