[systemd-devel] FW: pthread_create() fails SysV in myDaemon on boot

Michael D. Berger m.d.berger at ieee.org
Fri Nov 4 11:36:05 PDT 2011


> -----Original Message-----
> From: 
> systemd-devel-bounces+m.d.berger=ieee.org at lists.freedesktop.or
> g 
> [mailto:systemd-devel-bounces+m.d.berger=ieee.org at lists.freede
sktop.org] On Behalf Of Michal Schmidt
> Sent: Friday, November 04, 2011 13:36
> To: systemd-devel at lists.freedesktop.org
> Subject: Re: [systemd-devel] FW: pthread_create() fails SysV 
> in myDaemon on boot
[...]
> I'm guessing "--daemon" tells the program to daemonize itself.
> In that case you need to add "Type=forking" and "PIDFile=...".
> See "man systemd.service" for what other possibilities of 
> "Type=" there are.
> 
> Michal
[...]

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;
      }

I now have:

   [Unit]
   Description=myDaemon
   After=syslog.target network.target

   [Service]
   PIDFile=/var/lock/subsys/myDaemon
   Type=forking
   ControlGroupAttribute=cpu.rt_runtime_us 500000
   ExecStart=/usr/sbin/myDaemon --daemon

   [Install]
   WantedBy=multi-user.target

and it works as a systemd daemon and starts on boot iff:
DefaultControllers=

Also, I think that a change in "DefaultControllers=" requires
a reboot (or perhaps "systemctl restart <something>") to take
effect, which accouunts for some previous confusion.

So I still hope for additional information to get it
to work with:
#DefaultControllers=cpu

Thanks,
Mike.

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



More information about the systemd-devel mailing list