9103 opengroup acknowledgement should be properly formatted in man pages
[unleashed.git] / usr / src / man / man1 / nohup.1
blobc9db7d9b1167452c9b517177c82857453a84db6a
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright 1989 AT&T
44 .\" Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
45 .\" Copyright (c) 2006, Sun Microsystems, Inc.  All Rights Reserved.
46 .\"
47 .TH NOHUP 1 "Jun 19, 2006"
48 .SH NAME
49 nohup \- run a command immune to hangups
50 .SH SYNOPSIS
51 .LP
52 .nf
53 \fB/usr/bin/nohup\fR \fIcommand\fR [\fIargument\fR]...
54 .fi
56 .LP
57 .nf
58 \fB/usr/bin/nohup\fR \fB-p\fR [\fB-Fa\fR] \fIpid\fR [\fIpid\fR]...
59 .fi
61 .LP
62 .nf
63 \fB/usr/bin/nohup\fR \fB-g\fR [\fB-Fa\fR] \fIgpid\fR [\fIgpid\fR]...
64 .fi
66 .LP
67 .nf
68 \fB/usr/xpg4/bin/nohup\fR \fIcommand\fR [\fIargument\fR]...
69 .fi
71 .SH DESCRIPTION
72 .sp
73 .LP
74 The \fBnohup\fR utility invokes the named \fIcommand\fR with the arguments
75 supplied.  When the \fIcommand\fR is invoked, \fBnohup\fR arranges for the
76 \fBSIGHUP\fR signal to be ignored by the process.
77 .sp
78 .LP
79 When invoked with the \fB-p\fR or \fB-g\fR flags, \fBnohup\fR arranges for
80 processes already running as identified by a list of process \fBID\fRs or a
81 list of process group \fBID\fRs to become immune to hangups.
82 .sp
83 .LP
84 The \fBnohup\fR utility can be used when it is known that \fIcommand\fR takes a
85 long time to run and the user wants to log out of the terminal. When a shell
86 exits, the system sends its children \fBSIGHUP\fR signals, which by default
87 cause them to be killed. All stopped, running, and background jobs ignores
88 \fBSIGHUP\fR and continue running, if their invocation is preceded by the
89 \fBnohup\fR command or if the process programmatically has chosen to ignore
90 \fBSIGHUP\fR.
91 .sp
92 .ne 2
93 .na
94 \fB\fB/usr/bin/nohup\fR\fR
95 .ad
96 .RS 27n
97 Processes run by \fB/usr/bin/nohup\fR are immune to \fBSIGHUP\fR (hangup) and
98 \fBSIGQUIT\fR (quit) signals.
99 .RE
102 .ne 2
104 \fB\fB/usr/bin/nohup\fR \fB-p\fR [\fB-Fa\fR]\fR
106 .RS 27n
107 Processes specified by \fBID\fR are made immune to \fBSIGHUP\fR and
108 \fBSIGQUIT\fR, and all output to the controlling terminal is redirected to
109 \fBnohup.out\fR. If \fB-F\fR is specified, \fBnohup\fR forces control of each
110 process. If \fB-a\fR is specified, \fBnohup\fR changes the signal disposition
111 of \fBSIGHUP\fR and \fBSIGQUIT\fR even if the process has installed a handler
112 for either signal.
116 .ne 2
118 \fB\fB/usr/bin/nohup\fR \fB-g\fR [\fB-Fa\fR]\fR
120 .RS 27n
121 Every process in the same process group as the processes specified by \fBID\fR
122 are made immune to \fBSIGHUP\fR and \fBSIGQUIT\fR, and all output to the
123 controlling terminal is redirected to \fBnohup.out\fR. If \fB-F\fR is
124 specified, \fBnohup\fR forces control of each process. If \fB-a\fR is
125 specified, \fBnohup\fR changes the signal disposition of \fBSIGHUP\fR and
126 \fBSIGQUIT\fR even if the process has installed a handler for either signal.
130 .ne 2
132 \fB\fB/usr/xpg4/bin/nohup\fR\fR
134 .RS 27n
135 Processes run by \fB/usr/xpg4/bin/nohup\fR are immune to \fBSIGHUP\fR.
137 The \fBnohup\fR utility does not arrange to make processes immune to a
138 \fBSIGTERM\fR (terminate) signal, so unless they arrange to be immune to
139 \fBSIGTERM\fR or the shell makes them immune to \fBSIGTERM\fR, they will
140 receive it.
142 If \fBnohup.out\fR is not writable in the current directory, output is
143 redirected to \fB$HOME/nohup.out\fR. If a file is created, the file has read
144 and write permission (\fB600\fR. See \fBchmod\fR(1). If the standard error is a
145 terminal, it is redirected to the standard output, otherwise it is not
146 redirected. The priority of the process run by \fBnohup\fR is not altered.
149 .SH OPTIONS
152 The following options are supported:
154 .ne 2
156 \fB\fB-a\fR\fR
158 .RS 6n
159 Always changes the signal disposition of target processes. This option is valid
160 only when specified with \fB-p\fR or \fB-g\fR.
164 .ne 2
166 \fB\fB-F\fR\fR
168 .RS 6n
169 Force. Grabs the target processes even if another process has control. This
170 option is valid only when specified with \fB-p\fR or \fB-g.\fR
174 .ne 2
176 \fB\fB-g\fR\fR
178 .RS 6n
179 Operates on a list of process groups. This option is not valid with \fB-p\fR.
183 .ne 2
185 \fB\fB-p\fR\fR
187 .RS 6n
188 Operates on a list of processes. This option is not valid with \fB-g\fR.
191 .SH OPERANDS
194 The following operands are supported:
196 .ne 2
198 \fB\fIpid\fR\fR
200 .RS 12n
201 A decimal process \fBID\fR to be manipulated by \fBnohup\fR \fB-p\fR.
205 .ne 2
207 \fB\fIpgid\fR\fR
209 .RS 12n
210 A decimal process group \fBID\fR to be manipulated by \fBnohup\fR \fB-g\fR.
214 .ne 2
216 \fB\fIcommand\fR\fR
218 .RS 12n
219 The name of a command that is to be invoked. If the \fIcommand\fR operand names
220 any of the special \fBshell_builtins\fR(1) utilities, the results are
221 undefined.
225 .ne 2
227 \fB\fIargument\fR\fR
229 .RS 12n
230 Any string to be supplied as an argument when invoking the \fIcommand\fR
231 operand.
234 .SH USAGE
237 Caution should be exercised when using the \fB-F\fR flag. Imposing two
238 controlling processes on one victim process can lead to chaos. Safety is
239 assured only if the primary controlling process, typically a debugger, has
240 stopped the victim process and the primary controlling process is doing nothing
241 at the moment of application of the \fBproc\fR tool in question.
242 .SH EXAMPLES
244 \fBExample 1 \fRApplying nohup to pipelines or command lists
247 It is frequently desirable to apply \fBnohup\fR to pipelines or lists of
248 commands. This can be done only by placing pipelines and command lists in a
249 single file, called a shell script. One can then issue:
252 .in +2
254 example$ \fBnohup sh \fIfile\fR\fR      
256 .in -2
261 and the \fBnohup\fR applies to everything in \fIfile\fR. If the shell script
262 \fIfile\fR is to be executed often, then the need to type \fBsh\fR can be
263 eliminated by giving \fIfile\fR execute permission.
267 Add an ampersand and the contents of \fIfile\fR are run in the background with
268 interrupts also ignored (see \fBsh\fR(1)):
271 .in +2
273 example$ \fBnohup \fIfile\fR &\fR
275 .in -2
279 \fBExample 2 \fRApplying nohup -p to a process
281 .in +2
283 example$ \fBlong_running_command &\fR
284 example$ \fBnohup -p `pgrep long_running_command`\fR
286 .in -2
290 \fBExample 3 \fRApplying nohup -g to a process group
292 .in +2
294 example$ \fBmake &\fR
295 example$ \fBps -o sid -p $$\fR
296    SID
297 81079
298 example$ \fBnohup -g `pgrep -s 81079 make`\fR
300 .in -2
303 .SH ENVIRONMENT VARIABLES
306 See \fBenviron\fR(5) for descriptions of the following environment variables
307 that affect the execution of \fBnohup\fR: \fBLANG\fR, \fBLC_ALL\fR,
308 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, \fBPATH\fR, \fBNLSPATH\fR, and \fBPATH\fR.
310 .ne 2
312 \fB\fBHOME\fR\fR
314 .RS 8n
315 Determine the path name of the user's home directory: if the output file
316 \fBnohup.out\fR cannot be created in the current directory, the \fBnohup\fR
317 command uses the directory named by \fBHOME\fR to create the file.
320 .SH EXIT STATUS
323 The following exit values are returned:
325 .ne 2
327 \fB\fB126\fR\fR
329 .RS 7n
330 \fIcommand\fR was found but could not be invoked.
334 .ne 2
336 \fB\fB127\fR\fR
338 .RS 7n
339 An error occurred in \fBnohup\fR, or \fIcommand\fR could not be found
344 Otherwise, the exit values of \fBnohup\fR are those of the \fIcommand\fR
345 operand.
346 .SH FILES
348 .ne 2
350 \fB\fBnohup.out\fR\fR
352 .RS 19n
353 The output file of the \fBnohup\fR execution if standard output is a terminal
354 and if the current directory is writable.
358 .ne 2
360 \fB\fB$HOME/nohup.out\fR\fR
362 .RS 19n
363 The output file of the \fBnohup\fR execution if standard output is a terminal
364 and if the current directory is not writable.
367 .SH ATTRIBUTES
370 See \fBattributes\fR(5) for descriptions of the following attributes:
371 .SS "/usr/bin/nohup"
376 box;
377 c | c
378 l | l .
379 ATTRIBUTE TYPE  ATTRIBUTE VALUE
381 CSI     Enabled
384 .SS "/usr/xpg4/bin/nohup"
389 box;
390 c | c
391 l | l .
392 ATTRIBUTE TYPE  ATTRIBUTE VALUE
394 CSI     Enabled
396 Interface Stability     Standard
399 .SH SEE ALSO
402 \fBbatch\fR(1), \fBchmod\fR(1), \fBcsh\fR(1), \fBksh\fR(1), \fBnice\fR(1),
403 \fBpgrep\fR(1), \fBproc\fR(1), \fBps\fR(1), \fBsh\fR(1),
404 \fBshell_builtins\fR(1), \fBsignal\fR(3C), \fBproc\fR(4), \fBattributes\fR(5),
405 \fBenviron\fR(5), \fBstandards\fR(5)
406 .SH WARNINGS
409 If you are running the Korn shell (\fBksh\fR(1)) as your login shell, and have
410 \fBnohup\fR'ed jobs running when you attempt to log out, you are warned with
411 the message:
413 .in +2
415 You have jobs running.
417 .in -2
422 You need to log out a second time to actually log out. However, your background
423 jobs continues to run.
424 .SH NOTES
427 The C-shell (\fBcsh\fR(1)) has a built-in command \fBnohup\fR that provides
428 immunity from \fBSIGHUP\fR, but does not redirect output to \fBnohup.out\fR.
429 Commands executed with `\fB&\fR\&' are automatically immune to \fBHUP\fR
430 signals while in the background.
433 \fBnohup\fR does not recognize command sequences. In the case of the following
434 command,
436 .in +2
438 example$ \fBnohup command1; command2\fR
440 .in -2
445 the \fBnohup\fR utility applies only to \fBcommand1\fR. The command,
447 .in +2
449 example$ \fBnohup (command1; command2)\fR
451 .in -2
456 is syntactically incorrect.