Kai Grossjohann wrote: > >> > nuhup somecommand > somefile & sleep 1; tail -f somefile > Oh! Fascinating. Does nohup look with isatty(3) to determine what it > should do?
Yes. It looks at file descriptors 0, 1, and 2, and redirects any that are a tty device. So if you have already redirected them then nohup has nothing to do. But you need to redirect the other files too. If the input is a tty then it gets redirected from /dev/null. nohup somecommand > somefile 2>&1 & sleep 1; tail -f somefile But you don't need nohup these days. This should work just as well. somecommand > somefile 2>&1 </dev/null & sleep 1; tail -f somefile When you log out a hang up signal (aka SIGHUP) is sent to the process group associated with the controlling terminal. Before BSD-style job control in the AT&T V7 days all of the jobs were in that group. But with the new BSD-style job control kernels background tasks are all put into their own process group. This means that no hang up signal is sent to them anymore. So basically nohup is not so useful today as it was years ago. It is still useful to redirect the output to a nohup.out file. But it is no longer needed for background jobs to ignore the sighup signal when logging out. What *is* needed is a way to disassociate from the controlling terminal and to prevent processes from requiring a new one. But that does not easily exist. Bob
signature.asc
Description: Digital signature