[uClinux-dev] Daemonize a process
stuartm at connecttech.com
Thu Mar 13 12:33:50 EST 2003
From: "Robert Daniels" <robertd at vantagecontrols.com>
> Yeah, I never submitted my "fixes" to this since what is there works.
> I'll just attach my version of smbmount.c and you can check it out.
> This version has my own version of daemonize which seems to work fine
> for smbmount, and could maybe be adapted to your use. It is dependant
> on the /proc file system which might not be good, and it seems that it
> could use argv instead of a hardcoded "/smbmount" or "smbmount".
> Since this is based on vfork, it's tough to just put it anywhere in your
> code since it runs your program again starting from the beginning,
> but... better than nothing maybe.
Nifty. I'd thought of writing the daemon as a recursive app but I'd
been thinking the stopping condition would be passed as argv; the
/proc snooping is an interesting twist.
Fortunately for me the code that wants to be forked is already fairly
separated out; it's faster and easier for me to chop up the daemon
into a few smaller apps and use vfork(); execve(); instead.
More information about the uClinux-dev