On Thu, 26.05.11 12:53, Vasiliy G Tolstov ([email protected]) wrote:

> On Thu, 2011-05-26 at 16:52 +0800, microcai wrote:
> > 于 2011年05月26日 16:33, Vasiliy G Tolstov 写道:
> > > Hello. If i want to write daemon, that can be running by regular init
> > > system (openrc, upstart and others) and systemd, how can i check inside
> > > my daemon, that it runs from systemd?
> > > In compile phase, i can build with systemd support and install service
> > > file, but if i do not want to write and build separate binaries for two
> > > init daemons, how can i solve this?
> > > 
> > 
> > check sd-booted()
> > 
> 
> correct is sd_booted , thank you!

No, please don't. These interfaces have been designed in a way that
other init systems could use them too. If you however invoke sd_booted()
explicitly you ensure that your code won't work on other init systems
exposing the same interfaces.

sd_listen_fds() will return 0 if not used in a socket-activated
way. Hence, if you see this call return 0 then act as you did before and
allocate the sockets yourself.

sd_notify() becomes a NOP if no systemd-compatible init systemis
running, so just call it unconditionally.

So, really, there is no need, no need at all, to invoke sd_booted() to
guard these calls.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
_______________________________________________
systemd-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to