tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: rc.d: how to daemonize a non-daemonizing daemon?



On 13 Jun 2017, at 16:36, Edgar Fuß wrote:

I'm trying to write a sensible rc.d script for cups-browsed. Unfortunately,
cups-browsed itself does not daemonize. Now, that's not hard in shell:
	( cd /; cups-browsed "$@" <&- >&- 2>&- & echo "$!" >$pidfile ) &
but how do I incorporate that into an rc.d script? There seems to be no way to set command to a shell function executing that code. If I set my own start_cmd, I loose all the magic foo rc.subr does for me. do I need to put
that piece of code into a shell wrapper file or is there a simpler and
more elegant way?

Look at overriding start_precmd instead. Example: https://github.com/NetBSD/pkgsrc/blob/trunk/mail/qmail-run/files/qmailqread.sh

I'm not sure how I first figured this out, and I don't do all the daemonizing steps you've suggested, but this technique has been working pretty well for me for quite some time.

Home | Main Index | Thread Index | Old Index