]> git.pld-linux.org Git - projects/rc-scripts.git/commit
fix daemon --fork uses
authorKrzysztof Mazur <krzysiek@podlesie.net>
Thu, 26 Nov 2015 08:21:44 +0000 (09:21 +0100)
committerElan Ruusamäe <glen@delfi.ee>
Thu, 10 Dec 2015 20:24:19 +0000 (22:24 +0200)
commit7f7f7c7dbb36bfa3f7f84e60854cd0f334ff4296
tree18abad9e341c5d1a63c0e7740f1a13bf1dad66c5
parentf9ce7907e3cde407b2f6b57993e6274012a69ea7
fix daemon --fork uses

Recent rewrite of the daemon function (the commit
8714ffa414c8f182efa0bddf96486d99b89651bd: "daemon: rewrite $@ to
modify command, use runuser instead of su) broke support for --fork
without --makepid. Previously shells's '&' have been used to fork a new
process. Now the '&' is dropped. The --fork uses setsid to run a program
in a new session.  The setsid forks only if the current process is a
group leader (the progess group is equal to the process pid), which is
not true. As a result the new process is not forked and initlog waits
for deamon to stop (infinitely).  With --makepid everything works because
the makepid helper performs fork (using shell's '&').

Because the --makepid implies --fork, fix it by always using makepid
helper when --fork is used, and use /dev/null as pid file if --makepid
is not used.

---
Hi Elan,

I've just found another bug in rc-scripts after recent updates. The
"/etc/init.d/vsftpd start" stopped working. The initlog (PID 19735)
just forks, and starts a /usr/bin/setsid, which just execs to vsftpd
(without fork), and the initlog infinitely waits for vsftpd stop die:

[pid 19735] clone(child_stack=0, [...]) = 19736
[...]
[pid 19736] execve("/usr/bin/setsid", ["/usr/bin/setsid", "/usr/sbin/vsftpd"], [/* 25 vars */]) = 0
[...]
[pid 19736] getpgrp()                   = 19638
[pid 19736] getpid()                    = 19736
[pid 19736] setsid()                    = 19736
[pid 19736] execve("/usr/sbin/vsftpd", ["/usr/sbin/vsftpd"], [/* 25 vars */]) = 0
[...]
[pid 19735] wait4(19736, 0x7ffe0fd2c638, WNOHANG, NULL) = 0
[pid 19735] nanosleep({0, 500000}, NULL) = 0
[pid 19735] poll([{fd=3, events=POLLIN|POLLPRI}, {fd=5, events=POLLIN|POLLPRI}], 2, 500) = 0 (Timeout)
[pid 19735] wait4(19736, 0x7ffe0fd2c638, WNOHANG, NULL) = 0

Best regards,
Krzysiek
lib/functions
This page took 0.177182 seconds and 4 git commands to generate.