[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: nohup, but not nohup.out -- how to?

Kai Grossjohann wrote:
> The docs say that it is not necessary to redirect stderr;
> from (coreutils)nohup invocation:
>        If standard error is a terminal, it is redirected to the same file
>     descriptor as the standard output.

Reading that now I see that too.  A good catch.  (I think I was
thinking of the way nohup used to work a long time ago.  I should have

> It's interesting that the documentation of nohup does not talk about
> stdin.

Actually I was reading the code and not the documentation.  (In
general I often find documentation and comments in code to be very
misleading.  :-)

You caught a mistake I made in my posting.  What I said was not good
for Sarge.  Thanks for pointing that out.  Only for a later release
with the newer coreutils.  So for portability you really should always
redirect standard input from /dev/null explicitly and not count on
version differences in nohup.  Sorry for the mistake.

The newest nohup.c code has this snippet.

  /* If standard input is a tty, replace it with /dev/null.
     Note that it is deliberately opened for *writing*,
     to ensure any read evokes an error.  */
  if (isatty (STDIN_FILENO))
    fd_reopen (STDIN_FILENO, "/dev/null", O_WRONLY, 0);

But that snippet is from the bleeding edge upstream CVS version.  The
Sarge version does not have that section and does not close standard
input.  The Sarge version of the nohup program matches the Sarge
version of the documentation fine.  But the behavior will be changing
because of upstream changes in a future release.  This is documented
in the upstream CVS documentation which now says this:

     If standard input is a terminal, it is redirected from `/dev/null'
  so that terminal sessions do not mistakenly consider the terminal to be
  used by the command.  This is a GNU extension; programs intended to be
  portable to non-GNU hosts should use `nohup COMMAND [ARG]... </dev/null'


Attachment: signature.asc
Description: Digital signature

Reply to: