[systemd-devel] recommended way to detect systemd?

Lennart Poettering lennart at poettering.net
Sat Dec 29 11:57:44 PST 2012


On Sat, 29.12.12 13:40, Manuel Reimer (Manuel.Spam at nurfuerspam.de) wrote:

> Hello,
> 
> I need a reliable way to find out if a system, where my software
> runs on, uses systemd.
> 
> My first thought:
> 
> $ cat /proc/1/comm
> systemd

This won't always work as on many systems systemd is invoked via the
/sbin/init symlink in which case "comm" might be "init".

> Is this a reliable way that will also work in the next few releases
> of systemd, or should I use something different?

As mentioned, use "mountpoint -q /sys/fs/cgroup/systemd" in the shell
and "sd_booted()" in C (the latter does exactly the same thing internally
as the former).

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list