Pidfile generated by /usr/sbin/daemon not usable by rc.d script
Adam Lindberg
adam.lindberg at wooga.net
Wed May 25 09:51:35 UTC 2016
Hi!
I’m trying to create a minimal rc.d script for a service, and discovered that using /usr/sbin/daemon with the -p flag creates a pidfile which is not readable by /etc/rc.subr. The pidfile is created without a newline, in which case all the service commands stop working. That means, running “stop” or “status” prints nothing. If I add a newline to the file after the fact, they all start working again. Running the service script with debug output, shows the ‘read’ builtin halting the execution of the script when trying to read the pidfile.
Attached is the service script (“foo.rcscript”) and the output when it is broken, i.e. no newline (“service-foo-status-without-newline.output”) and when it works after manually adding the newline to the pidfile (“service-foo-status-with-newline.output”).
The service script as a ‘sed’ line commented out, which if enabled will make the service script work. However, it feels like a bit of a hack to modify the pidfile created by ‘daemon’ manually afterwards.
Is there a better way to make this work? Is this a bug somehow, either in the service script I wrote or in the rc.subr functions? Any insight would be helpful.
Thanks in advance!
Adam
--
Adam Lindberg | Backend Engineer
Wooga GmbH | Saarbrücker Str. 38 | D-10405 Berlin
Place of business: Berlin
Registered at the local court Berlin-Charlottenburg, HRB 117846 B
Managing Directors: Jens Begemann, Philipp Möser, Jan Miczaika
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.rcscript
Type: application/octet-stream
Size: 329 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20160525/9dd53ba1/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: service-foo-status-with-newline.output
Type: application/octet-stream
Size: 14493 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20160525/9dd53ba1/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: service-foo-status-without-newline.output
Type: application/octet-stream
Size: 12667 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20160525/9dd53ba1/attachment-0002.obj>
More information about the freebsd-questions
mailing list