Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/coreutils/nohup.c

    r1765 r2725  
    66 *
    77 * Copyright 2006 Rob Landley <rob@landley.net>
    8  * Copyright 2006 Bernhard Fischer
     8 * Copyright 2006 Bernhard Reutner-Fischer
    99 *
    10  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
     10 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    1111 */
    1212
    1313#include "libbb.h"
    1414
    15 int nohup_main(int argc, char **argv);
    16 int nohup_main(int argc, char **argv)
     15/* Compat info: nohup (GNU coreutils 6.8) does this:
     16# nohup true
     17nohup: ignoring input and appending output to `nohup.out'
     18# nohup true 1>/dev/null
     19nohup: ignoring input and redirecting stderr to stdout
     20# nohup true 2>zz
     21# cat zz
     22nohup: ignoring input and appending output to `nohup.out'
     23# nohup true 2>zz 1>/dev/null
     24# cat zz
     25nohup: ignoring input
     26# nohup true </dev/null 1>/dev/null
     27nohup: redirecting stderr to stdout
     28# nohup true </dev/null 2>zz 1>/dev/null
     29# cat zz
     30  (nothing)
     31#
     32*/
     33
     34int nohup_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     35int nohup_main(int argc UNUSED_PARAM, char **argv)
    1736{
    18     int nullfd;
    1937    const char *nohupout;
    20     char *home = NULL;
     38    char *home;
    2139
    2240    xfunc_error_retval = 127;
    2341
    24     if (argc < 2) bb_show_usage();
     42    if (!argv[1]) {
     43        bb_show_usage();
     44    }
    2545
    26     nullfd = xopen(bb_dev_null, O_WRONLY|O_APPEND);
    2746    /* If stdin is a tty, detach from it. */
    28     if (isatty(STDIN_FILENO))
    29         dup2(nullfd, STDIN_FILENO);
     47    if (isatty(STDIN_FILENO)) {
     48        /* bb_error_msg("ignoring input"); */
     49        close(STDIN_FILENO);
     50        xopen(bb_dev_null, O_RDONLY); /* will be fd 0 (STDIN_FILENO) */
     51    }
    3052
    3153    nohupout = "nohup.out";
     
    3860                nohupout = concat_path_file(home, nohupout);
    3961                xopen3(nohupout, O_CREAT|O_WRONLY|O_APPEND, S_IRUSR|S_IWUSR);
     62            } else {
     63                xopen(bb_dev_null, O_RDONLY); /* will be fd 1 */
    4064            }
    4165        }
    42     } else dup2(nullfd, STDOUT_FILENO);
     66        bb_error_msg("appending output to %s", nohupout);
     67    }
    4368
    44     /* If we have a tty on stderr, announce filename and redirect to stdout.
    45      * Else redirect to /dev/null.
    46      */
     69    /* If we have a tty on stderr, redirect to stdout. */
    4770    if (isatty(STDERR_FILENO)) {
    48         bb_error_msg("appending to %s", nohupout);
     71        /* if (stdout_wasnt_a_tty)
     72            bb_error_msg("redirecting stderr to stdout"); */
    4973        dup2(STDOUT_FILENO, STDERR_FILENO);
    50     } else dup2(nullfd, STDERR_FILENO);
     74    }
    5175
    52     if (nullfd > 2)
    53         close(nullfd);
    5476    signal(SIGHUP, SIG_IGN);
    5577
    56     BB_EXECVP(argv[1], argv+1);
    57     if (ENABLE_FEATURE_CLEAN_UP && home)
    58         free((char*)nohupout);
    59     bb_perror_msg_and_die("%s", argv[1]);
     78    argv++;
     79    BB_EXECVP_or_die(argv);
    6080}
Note: See TracChangeset for help on using the changeset viewer.