ssh -f won't detach properly when run from cron.

Damien Miller djm at mindrot.org
Tue Jul 26 08:08:12 EST 2005


fraff wrote:
> Hi,
> 
> In file ssh.c, in function "ssh_session2", this piece of code:
> 
> /* If requested, let ssh continue in the background. */
> if (fork_after_authentication_flag)
>     if (daemon(1, 1) < 0)
>         fatal("daemon() failed: %.200s", strerror(errno));
> 
> implements the "-f" option, but when run from cron, it does not detach
> properly because of the second parameter (noclose) of the daemon() function.
> 
> The result is a defunct process and a CRON process waiting for ssh to
> exit.
> 
> I don't understand why the "noclose" parameter of daemon() is set to
> "1", could somebody explain ?

Because you may still want output from the backgrounded command.

Try ssh -nf ... >/dev/null 2>&1

-d




More information about the openssh-unix-dev mailing list