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 ?
thanks for all.
--
fraff
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
Seemingly Similar Threads
- ssh -f and -O ControlPersist=yes, ControlMaster=yes leaves stderr open
- X11 forwarding, -f, error handling
- FEATURE: -f -f - fork after successful open of fwd port/display/agent
- 2.9p2 behaves different from 2.5.2p2 on tunneling issue
- Patch to allow openssh-2.2.0-p1 to be started from /etc/inittab