On Thu, 24.09.15 13:18, Jonathan de Boyne Pollard (j.deboynepollard-newsgro...@ntlworld.com) wrote:
> In an ideal world you would be able to have a routine that detected the > running > system manager, and then did whatever was appropriate to that system manager > to > power off, from sending signals to process #1 through running the System 5 > init/rc clone's "shutdown -h -P now" command to sending requests to upstart's > Desktop Bus API. In the real world, all of the problems that make detecting > the > running system manager really difficult to do that are described at > http://unix.stackexchange.com/a/196252/5132 rear their ugly heads. (A further > problem not mentioned there: Joachim Nilsson's finit also responds to "initctl > version".) That stackexchange link lists a pile of garbage. We have an official API to check whether the system is booted with systemd: sd_booted(). It's documented here: http://www.freedesktop.org/software/systemd/man/sd_booted.html And we even document on that man page what precisely it does internally (which is equivalent to access("/run/systemd/system/", F_OK) >= 0) and suggest people to reimplement that simple check in the language of their choice, even in shell... That way, they don't even have to link against libsystemd. Lennart -- Lennart Poettering, Red Hat _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel