Comment 4 for bug 264711

Revision history for this message
Jeff Oliver (jeffrey-oliver) wrote : Re: expect fork/daemon do not work as expected

After playing around with it more and tracing through the code, the child fork state machine doesn't work right if the job file does not have the 'session leader' stanza.

Without session leader, the new process is not a directly forked from upstart, so the traps seem to get lost, or at least incorrectly interpreted. The trace gets setup on the correct pid, but the signals go to the parent, which is not upstart.

In any case, it looks like it'd be a mess to try and trace non-session leaders, if that was even a legitimate use case. Its just easier to set session leader on the jobs that need to be traced.

Is it possible to imply session leader if expect fork exists? Or is my logic all wrong?

Btw, a dump of what a working fork looks like: I used portmap this time:
2008-10-10T02:13:25.086613+00:00 fs03 init: portmap goal changed from stop to start
2008-10-10T02:13:25.086645+00:00 fs03 init: portmap state changed from waiting to starting
2008-10-10T02:13:25.086677+00:00 fs03 init: waitid - pid=0, signo=0, code=0, status=0
2008-10-10T02:13:25.086709+00:00 fs03 init: Handling starting event
2008-10-10T02:13:25.086742+00:00 fs03 init: portmap state changed from starting to pre-start
2008-10-10T02:13:25.086774+00:00 fs03 init: portmap state changed from pre-start to spawned
2008-10-10T02:13:25.087224+00:00 fs03 init: setup trace on pid 0
2008-10-10T02:13:25.087400+00:00 fs03 init: portmap main process (3838)
2008-10-10T02:13:25.087514+00:00 fs03 init: waitid - pid=3838, signo=17, code=4, status=5
2008-10-10T02:13:25.087614+00:00 fs03 init: portmap main process (3838) trapped
2008-10-10T02:13:25.088015+00:00 fs03 init: waitid - pid=3839, signo=17, code=4, status=19
2008-10-10T02:13:25.088114+00:00 fs03 init: waitid - pid=0, signo=0, code=0, status=0
2008-10-10T02:13:25.088245+00:00 fs03 init: waitid - pid=0, signo=0, code=0, status=0
2008-10-10T02:13:25.088358+00:00 fs03 init: waitid - pid=3838, signo=17, code=4, status=261
2008-10-10T02:13:25.088460+00:00 fs03 init: portmap main process (3838) became new process (3839)
2008-10-10T02:13:25.088560+00:00 fs03 init: waitid - pid=0, signo=0, code=0, status=0
2008-10-10T02:13:25.088707+00:00 fs03 init: waitid - pid=3838, signo=17, code=1, status=0
2008-10-10T02:13:25.088810+00:00 fs03 init: waitid - pid=0, signo=0, code=0, status=0
2008-10-10T02:13:50.086811+00:00 fs03 init: waitid - pid=0, signo=0, code=0, status=0