[uClinux-dev] Daemonize a process

Stuart MacDonald stuartm at connecttech.com
Thu Mar 13 10:34:46 EST 2003


From: "Robert Daniels" <robertd at vantagecontrols.com>
> You might want to check the code for smbmount for an example of an
> application that does the daemonize thing.  It's under
> user/samba/source/client/smbmount.c.  It was modified to not call its
> own daemonize function and instead, it will go into a loop where it will
> kill its parent (most likely your shell) and keep running.  It's a

I just now looked at that. The standard daemonise sequence is
#ifndef EMBED, and the vfork sequence execve's smbmnt. This is likely
the code path I'll have to use, but I don't see where it kills off its
parent process.

> if this will work in your situation or not.  I modified this code to use
> a goofy version of daemonize in which I use vfork and execv to spawn off
> a daemon process.  The trick here is to make sure you don't recursively
> daemonize, which I accomplished by snooping the /proc filesystem.

I also don't see the snooping. Could you point out line #s? I'm using
uClinux-dist-20020927 ATM, but also have -20030305 handy.

..Stu





More information about the uClinux-dev mailing list