On Sun, Sep 09, 2018 at 11:13:40AM +0800, Nan Xiao wrote:
> Honestly, I am still a little confused:

Let's explain more context.  Recently I found some deamons that
accidently closed stdin, so I am sensible for this kind of error.

nohup(1) tries to use nohup.out for stdout or stderr in some cases.
If the file descriptors are closed in advance, this does not work.
To fix these additional cases, I think we should also redirect to
nohup.out if stdout or stderr is closed.

> "nohup true 2>&-" means close stderr of nohup, right?

Yes.

> > errno = 0;
> > if (isatty(STDOUT_FILENO) || errno == EBADF)
> 
> Since we close stderr, why do we need additional check of stdout here?

We should check both stdout and stderr.  This is just an example
how the check could work.  Logic should be to redirect stdout or
stderr to nohup.out, if it is a tty or if it has been closed.

bluhm

Reply via email to