The init process exists as an ancestor of all of processes on a linux system. Does this process have any kind of IPC entry point ? Do other processes ever do IPC with init for any reason ?
Asked
Active
Viewed 557 times
1 Answers
10
Don't conflate processes and programs. There's one process #1, but it can be running one of a number of different programs.
- If it is running the
systemdprogram from the systemd package:- There is an internal systemd API accessible via D-Bus, that is not guaranteed stable and not intended to be used by things outwith the systemd package.
- It responds to a large set of signals, ranging from
SIGWINCHandSIGPWRtoSIGRTMIN + 4.
- If it is running the
system-managerprogram from the nosh package:- It responds to a fairly large subset of the signals recognized by
systemd, with the same meanings where applicable.
- It responds to a fairly large subset of the signals recognized by
- If it is running the
initprogram from upstart:- There is an internal upstart API, accessible via D-Bus.
- It reads command messages from the
initctlFIFO. - It responds to small set of signals.
- If it is running Joachim Nilsson's
finit:- It reads command messages from the
initctlFIFO. - It responds to a small set of signals.
- It reads command messages from the
- If it is running the System 5
initthen:- It reads command messages from the
initctlFIFO. - It responds to a very small set of signals.
- It reads command messages from the
Some notes:
- The signal API is mandated by the things that send the signals to process #1. These include the operating system kernel, which sends things like
SIGWINCH,SIGINT, andSIGPWR, and various widespread system utility programs.- Both
systemdand the noshsystem-managerextend this with signals that command system state changes (such as shutting down and powering off the system). - Not all programs document supporting the full set of system-mandated signals. upstart makes no mention of responding to
SIGPWR, for example. finitrecognizes a different set of non-system-mandated extended signals, includingSIGSTOPandSIGCONT.
- Both
- Although the systemd package doesn't implement the
initctlFIFO API in the program that runs as process #1, it does provide a compatibility shim in another process, running another program, that translates that mechanism onto native systemd mechanisms. (The nosh toolset has its owninitctl-readcompatibility shim that similarly translated into the native mechanisms of the nosh toolset's system management.)initctlreally isn't native to anything but System Vinit, as the others (if they do so at all) only implement the notion of run levels as a limited backwards-compatibility mechanism.- As the upstart man page for its
initprogram says, theinitctlmechanism isn't well documented. Even the System Vinitpeople go around telling people that only things in the System Vinitpackage should use it. It doesn't help, moreover, that the Debian System V maintainers relocated it from/devto/run.
So yes, programs do IPC with process #1. Their reasons for doing so vary.
- The
systemdprogram is a combination system manager, service manager, and control groups manager and so there are a lot of purposes for which programs employ IPC to process #1. The same for upstart'sinit. - For nosh's
system-manager, conversely, service management is done by another program (service-manager) in another process with its own (daemontools-compatible) APIs. So the only reason to do IPC with process #1 is for system state management, such as (say) rebooting the machine.
For many (not all) purposes, one is better off sticking to other APIs, using conventional system utilities to do things like shutdown and reboot the system, rather than sending the signals understood by the system-manager and systemd programs when they are running as process #1.
Further reading
JdeBP
- 68,745
initctlto tellinit(I'm not doing anything with that there new-fangledsystemdthingy - at least not until it gets to be a lot more stable in extreme cases) when the Main power has dropped and come back - and when to shut down because the battery is running critically low. The intricacies are not that complex but I am using it because that is exactly what that API is intended for. – SlySven Feb 29 '16 at 07:32Finit also supports UNIX domain socket IPC.
– troglobit Mar 23 '19 at 13:05