NAME
nohup
—
inoculate invocation against
hang-ups
SYNOPSIS
nohup |
[-- ] program
[argument]… |
DESCRIPTION
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:
- ignoring
SIGHUP
(see signal(7) for its circumstances and consequences), - 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
, - if the standard output stream is a teletype, appending it to
nohup.out, or, should that fail,
$HOME
/nohup.out (provided theHOME
environment variable is set), creating the file asu=rw
if necessary, - if the standard error stream is a teletype, binding it to the standard output stream, and finally
- 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.
ENVIRONMENT
HOME
- The fallback location for nohup.out.
PATH
- In which program is searched, confer execvp(3).
EXIT STATUS
- 127
- program wasn't found or an error was encountered during set-up.
- 126
- program exists, but couldn't be executed for a different reason.
- All others
- returned by program.
SEE ALSO
STANDARDS
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 125 for set-up errors.
HISTORY
Appeared in Version 4 AT&T UNIX as
Version 7 AT&T UNIX sees
a merged manual page with
nice(1), and a shell implementation ignoring
SIGHUP
and SIGTERM
,
increasing niceness by
5, and redirecting all
output to nohup.out if the standard error stream is
a teletype:
trap
""
1 15if
test
-t
2>&1 ;
then
echo
"Sending output to 'nohup.out'"
exec
nice
-5
$*>>
nohup.out2>&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 2 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".
Standards
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.