strace'ing journald while calling "logger foo" reveals: clock_gettime(CLOCK_BOOTTIME, {124771, 959412867}) = 0 ioctl(3, FIONREAD, [30]) = 0 recvmsg(3, {msg_name(0)={sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, msg_iov(1)=[{"<13>Jan 21 17:55:28 smurf: foo", 24575}], msg_controllen=64, {cmsg_len=32, cmsg_level=SOL_SOCKET, cmsg_type=0x1d /* SCM_??? */, ...}, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_CMSG_CLOEXEC) = 30 sendmsg(3, {msg_name(29)={sa_family=AF_LOCAL, sun_path="/run/systemd/journal/syslog"}, msg_iov(1)=[{"<13>Jan 21 17:55:28 smurf: foo", 30}], msg_controllen=28, {cmsg_len=28, cmsg_level=SOL_SOCKET, cmsg_type=SCM_CREDENTIALS{pid=14495, uid=501, gid=501}}, msg_flags=0}, MSG_NOSIGNAL) = -1 ESRCH (No such process) sendmsg(3, {msg_name(29)={sa_family=AF_LOCAL, sun_path="/run/systemd/journal/syslog"}, msg_iov(1)=[{"<13>Jan 21 17:55:28 smurf: foo", 30}], msg_controllen=28, {cmsg_len=28, cmsg_level=SOL_SOCKET, cmsg_type=SCM_CREDENTIALS{pid=579, uid=501, gid=501}}, msg_flags=0}, MSG_NOSIGNAL) = -1 ECONNREFUSED (Connection refused) open("/proc/14495/cgroup", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/proc/14495/comm", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) readlinkat(AT_FDCWD, "/proc/14495/exe", 0x7fa6e89c8b30, 99) = -1 ENOENT (No such file or directory) open("/proc/14495/cmdline", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/proc/14495/status", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/proc/14495/sessionid", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/proc/14495/loginuid", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/proc/14495/cgroup", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) ftruncate(18, 16777216) = 0 ioctl(3, FIONREAD, [0]) = 0 recvmsg(3, 0x7fff18b3e670, MSG_DONTWAIT|MSG_CMSG_CLOEXEC) = -1 EAGAIN (Resource temporarily unavailable) epoll_wait(8, ^C That first sendmsg() call returns ESRCH. Therefore, all these accesses to /proc/ are by definition superfluous overhead. Please don't do them.
Well, it's not that easy. ENOENT doesn't tell us if a process is dead or just that file we look for not exposed by the kernel. Things like loginuid, cgroup or sessionid are all kernel optional, so just considering processes dead where they are missing is too simple...
THis has been implemented in systemd 235. Closing.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.