[systemd-devel] removing daemon(0,0)

Michael D. Berger m.d.berger at ieee.org
Fri Nov 4 17:19:44 PDT 2011


> -----Original Message-----
> From: Michal Schmidt [mailto:mschmidt at redhat.com] 
> Sent: Friday, November 04, 2011 17:45
> To: Michael D. Berger
> Cc: systemd-devel at lists.freedesktop.org
> Subject: Re: [systemd-devel] FW: pthread_create() fails SysV 
> in myDaemon on boot
> 
> On Fri, 04 Nov 2011 14:36:05 -0400 Michael D. Berger wrote:
> > Your assumption is correct.  In the code I have:
> >       if (argc == 2)
> >       {
> >          string   arg = argv[1];
> >          if (arg != "--daemon")
> >             throw ...
> >          ::daemon(0,0);
> >          isDaemon = true;
> >       }
> 
> Not related to your problem with the cpu cgroup controller, but ...
> daemon(3) is not the best way to daemonize a process. I 
> suggest you to take a look at 
> http://0pointer.de/public/systemd-man/daemon.html
> 
> Michal

As you see, I made a new thread of this.

Looking at the recommended document, I concluded, perhaps
incorrectly, that I should remove my
   daemon(0,0);
and add:
   const char* const    state = "OK";
   sd_notify(1/*unset_environment*/,state);

"man sd_notify" says the include file is
   #include "sd-daemon.h"
but the only one like this is:
   #include </usr/share/doc/systemd/sd-daemon.h>
I suuppose that I should have expected that ld can't find
"sd-daemon", but I see:
   /usr/share/doc/systemd/sd-daemon.c

Should I get it and compile it, or am I up the wrong tree?
This is looking a little odd.

I tried just removing "daemon(0,0)", but
   systemctl start myDaemon.service
does not return, so it looked like sd_notify() might be 
a good thing.

Thanks,
Mike.


--
Michael D. Berger
m.d.berger at ieee.org
http://www.rosemike.net/
   



More information about the systemd-devel mailing list