Header cleanup on two more networking files (move libbb.h to the top and
[oweals/busybox.git] / coreutils / nohup.c
index ea1c4c55a0a11f738f2c8af8483b13edd6cfc36c..9d7a0f5597173ac1d33d2cc9e49166e3ab5b65d5 100644 (file)
@@ -2,7 +2,7 @@
 /* nohup - invoke a utility immune to hangups.
  * 
  * Busybox version based on nohup specification at
- * http://www.opengroup.org/onlinepubs/007904975/utilities/sed.html
+ * http://www.opengroup.org/onlinepubs/007904975/utilities/nohup.html
  * 
  * Copyright 2006 Rob Landley <rob@landley.net>
  * 
@@ -10,6 +10,7 @@
  */
 
 #include <fcntl.h>
+#include <signal.h>
 #include <unistd.h>
 #include "busybox.h"
 
@@ -18,6 +19,10 @@ int nohup_main(int argc, char *argv[])
        int temp, nullfd;
        char *nohupout = "nohup.out", *home = NULL;
 
+       // I have no idea why the standard cares about this.
+
+       bb_default_error_retval = 127;
+
        if (argc<2) bb_show_usage();
 
        nullfd = bb_xopen(bb_dev_null, O_WRONLY|O_APPEND);
@@ -44,8 +49,8 @@ int nohup_main(int argc, char *argv[])
        temp = isatty(2);
        if (temp) fdprintf(2,"Writing to %s\n", home ? home : nohupout);
        dup2(temp ? 1 : nullfd, 2);
-
        close(nullfd);
+       signal (SIGHUP, SIG_IGN);
 
        // Exec our new program.