[uClinux-dev] Daemonize a process
stuartm at connecttech.com
Sun Mar 16 21:12:23 EST 2003
From: "Stuart MacDonald" <stuartm at connecttech.com>
> 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.
For the archives: Robert's code from elsewhere in this thread works,
and is reasonably easy to implement. It does depend on /proc, but then
so do other things like ps.
More information about the uClinux-dev