In recent systemd-nspawn we wouldn't parse init args like systemd.log-level=debug.
This is because we wouldn't even look at /proc/1/cmdline.
$ systemd-nspawn -n cat /proc/1/stat
1 (cat) R 0 1 1 34816 ....
^^^^^
34816 is 136:0 a.k.a. /dev/pts/0.
const char *e;
- if (get_ctty_devnr(0, NULL) < 0)
- /* Only try to read the command line in daemons. We assume that anything that has a controlling tty is
- user stuff. */
+ if (getpid_cached() == 1 || get_ctty_devnr(0, NULL) < 0)
+ /* Only try to read the command line in daemons. We assume that anything that has a
+ * controlling tty is user stuff. For PID1 we do a special check in case it hasn't
+ * closed the console yet. */
(void) proc_cmdline_parse(parse_proc_cmdline_item, NULL, PROC_CMDLINE_STRIP_RD_PREFIX);
e = getenv("SYSTEMD_LOG_TARGET");