Comment 1 for bug 926468

Revision history for this message
Jason Conti (jconti) wrote :

I think the attached source file, along with a simple upstart conf with: exec /path/to/test-daemon may be a minimal example of the behavior.

sshd is spawned by upstart with -D so the initial process doesn't daemonize. The upstart logging mechanism will setup a pty for stdout/stderr. When receiving a connection, sshd forks and daemonizes, but looking at /proc/pid/fd/ it appears to omit redirecting stderr to /dev/null, so the pty is still opened on fd 2.

So when the ssh service is stopped, the inital sshd instance run with -D is terminated, but the child sshd keeps running and still has the pty open. Then when upstart flushes the log and waits for the fd to error out in log_read_watch, it loops forever with EAGAIN until the child exits.

I think that is what is going on anyway, and the attached code exhibits similar behavior.