NOHUP(1) General Commands Manual NOHUP(1)

nohupinoculate invocation against hang-ups

nohup [--] program [argument]…

nohup protects an invocation of program against undue termination due to a dropped login session. It cannot protect against a more sophisticated job reaping system.

It does so by:

  1. ignoring SIGHUP (see signal(7) for its circumstances and consequences),
  2. if the standard input stream is a teletype, binding it to a write-only /dev/null stream, such that reads therefrom will hence fail with EBADF,
  3. if the standard output stream is a teletype, appending it to nohup.out, or, should that fail, $HOME/nohup.out (provided the HOME environment variable is set), creating the file as u=rw if necessary,
  4. if the standard error stream is a teletype, binding it to the standard output stream, and finally
  5. executing program arguments, searching for program in the PATH.

If any standard I/O stream was unopened, it will remain unopened. Failure to open /dev/null or both nohup.outs when required is a fatal error.

If any standard I/O stream is a teletype, a summary of redirexions and the location of the file are written to the standard error stream before being redirected.

The fallback location for nohup.out.
In which program is searched, confer execvp(3).

program wasn't found or an error was encountered during set-up.
program exists, but couldn't be executed for a different reason.
All others
returned by program.

login(1), execvp(3), signal(7)

Conforms to IEEE Std 1003.1-2008 (“POSIX.1”); redirecting the standard input stream is an optional feature, and isn't widely implemented outside of the GNU system — prefer < /dev/null for portability.

Noting stream redirexions if the standard output stream is not a teletype is an extension, also present on the GNU system, which also exits for set-up errors.

Appeared in Version 4 AT&T UNIX as

nohup - run a command immune to hangups
executing program "with hangups, quits and interrupts all ignored".

Version 7 AT&T UNIX sees a merged manual page with nice(1), and a shell implementation ignoring SIGHUP and SIGTERM, increasing niceness by , and redirecting all output to nohup.out if the standard error stream is a teletype:

trap "" 1 15
if test -t 2>&1  ;  then
        echo "Sending output to 'nohup.out'"
        exec nice -5 $* >>nohup.out 2>&1
else
        exec nice -5 $* 2>&1
fi

4.3BSD-Reno quotes IEEE Std 1003.2 (“POSIX.2”) compatibility, but "appends" to nohup.out with a single lseek(SEEK_END);, exits 1 on all errors, and also ignores SIGQUIT.

AT&T System III UNIX ignores SIGHUP and SIGQUIT, exits on a setup error, and handles standard output and error streams as present-day, If executing program fails, the error is written to /dev/tty.

AT&T System V Release 1 UNIX exits 1 on setup errors and writes the actual execvp(3) error rather than always "not found".

X/Open Portability Guide Issue 2 (“XPG2”) specifies AT&T System III UNIX verbatim.

X/Open Portability Guide Issue 4 (“XPG4”) specifies only SIGHUP, noting that extant implementations variably also ignore either SIGQUIT or SIGTERM.

IEEE Std 1003.1-2008 (“POSIX.1”) allows for the standard input stream to be redirected from an "unspecified file" if it's a teletype, following the GNU system.

April 24, 2023 voreutils pre-v0.0.0-latest