Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

distccd --no-detach outlives its parent process #129

Open
GoogleCodeExporter opened this issue May 26, 2015 · 2 comments
Open

distccd --no-detach outlives its parent process #129

GoogleCodeExporter opened this issue May 26, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

trunk r780 on Debian sid

Originally reported at <http://bugs.debian.org/709169>.


NoDetachDaemon_Case leaves the daemon process running.  Maybe specific to 
Debians sh (dash 0.5.7).  I shall patch this in trunk if someone confirms this 
effects other systems.


$ PATH="`pwd`:/usr/local/bin:/bin:/usr/bin" PYTHONPATH="`pwd`/test" python2.7 
Python 2.7.3 (default, Mar  5 2013, 01:19:40) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import testdistcc
>>> obj = testdistcc.NoDetachDaemon_Case()
>>> obj.setup()
>>> print obj.pid # the process reaped by killDaemon
3905
>>> print open(obj.daemon_pidfile, "r").read()
3906

>>> �

[1]+  Stopped                 PATH="`pwd`:/usr/local/bin:/bin:/usr/bin" 
PYTHONPATH="`pwd`/test" python2.7
$ ps xf | grep distccd | grep -v grep
 3905 pts/1    T      0:00  |   \_ /bin/sh -c distccd «ARGS»
 3906 pts/1    SN     0:00  |       \_ distccd «ARGS»
 3907 pts/1    SN     0:00  |           \_ distccd «ARGS»
 3908 pts/1    SN     0:00  |           \_ distccd «ARGS»
 3909 pts/1    SN     0:00  |           \_ distccd «ARGS»
$ fg
PATH="`pwd`:/usr/local/bin:/bin:/usr/bin" PYTHONPATH="`pwd`/test" python2.7

>>> obj.killDaemon()
>>> 
$ ps xf | grep distccd | grep -v grep
 3906 pts/1    SN     0:00 distccd «ARGS»
 3907 pts/1    SN     0:00  \_ distccd «ARGS»
 3908 pts/1    SN     0:00  \_ distccd «ARGS»
 3909 pts/1    SN     0:00  \_ distccd «ARGS»
$ 


The log file confirms “not detaching”.

You can see that ‘killDaemon’ reaps the shell process and the daemon 
process survives.  To me that seems strange and perhaps a bug; is there some 
reason why the daemon should outlive the shell when ‘--no-detach’ is used?

Original issue reported on code.google.com by mand...@gmail.com on 25 May 2013 at 4:51

@GoogleCodeExporter
Copy link
Author

> Maybe specific to Debians sh (dash 0.5.7).

Not so.  The daemon creates its own process group, and the signal sent to the 
shell does not reach it.

Creating a process group even with --no-detach was added in 2003 by mbp.  I 
suppose because this is desirable for managing the children.  Without reworking 
the child management, --no-detach can use various non-portable ways to detect 
the death of its parent as suggested in [1].


Original comment by mand...@gmail.com on 27 May 2013 at 5:03

  • Changed title: distccd --no-detach outlives its parent process

@GoogleCodeExporter
Copy link
Author

[1] 
<http://stackoverflow.com/questions/284325/how-to-make-child-process-die-after-p
arent-exits>

The Linux suggestion of course works:
 prctl(PR_SET_PDEATHSIG, SIGHUP);

others could be use depending on the platform in a best effort approach.

Original comment by mand...@gmail.com on 27 May 2013 at 5:17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant