As we all know, when we reboot, shutdown or startup a system, some message will be printed on the screen, here is a capture:
My system is Ubuntu 16.04, I know these log messages as above come from the systemd.
As my understanding, a normal user-process can print things on the screen because the system gives it three file descriptors: 0, 1 and 2. We can find them at /proc/<PID>/fd/
. Here is an example:
root@X86-Xenial-6:~# ls /proc/3467/fd
0 1 2 255
The 3467
is a hello-world program, I don't know what 225
is but I know that 0
, 1
and 2
are standard input, standard output and standard error.
So, I have a question: when the system starts to shutdown, reboot or startup, user-process hasn't been created or has been destroyed, which means that /proc/
doesn't exist anymore, in this case, 0
, 1
and 2
doesn't exist.
So why does the message coming from systemd can be printed on the screen? The kernel could print things because it controls the screen immediately, but I don't think systemd belongs to the kernel, so how could it print things on the screen too? What kind of function or api is used?