]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pid1: always log successfull process termination quietly
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 21 Aug 2019 14:20:59 +0000 (16:20 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 22 Aug 2019 07:09:45 +0000 (09:09 +0200)
Fixes #13372.

src/core/mount.c
src/core/service.c
src/core/socket.c
src/core/swap.c
src/core/unit.c
src/core/unit.h

index fb6a516318d6d03e2a1674aeae40d7352bb41a4f..4f37d3e9a9bfab769a8ba15d2f3e0022fb080bae 100644 (file)
@@ -1323,9 +1323,10 @@ static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) {
         }
 
         unit_log_process_exit(
-                        u, f == MOUNT_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
+                        u,
                         "Mount process",
                         mount_exec_command_to_string(m->control_command_id),
+                        f == MOUNT_SUCCESS,
                         code, status);
 
         /* Note that due to the io event priority logic, we can be sure the new mountinfo is loaded
index d1893228ece4f35d3b02611219814a9c3099a6e9..d8cfb4014555aa4b6379c67d2fb3ebfc03773c87 100644 (file)
@@ -3417,14 +3417,11 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
                                 f = SERVICE_SUCCESS;
                 }
 
-                /* When this is a successful exit, let's log about the exit code on DEBUG level. If this is a failure
-                 * and the process exited on its own via exit(), then let's make this a NOTICE, under the assumption
-                 * that the service already logged the reason at a higher log level on its own. (Internally,
-                 * unit_log_process_exit() will possibly bump this to WARNING if the service died due to a signal.) */
                 unit_log_process_exit(
-                                u, f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
+                                u,
                                 "Main process",
                                 service_exec_command_to_string(SERVICE_EXEC_START),
+                                f == SERVICE_SUCCESS,
                                 code, status);
 
                 if (s->result == SERVICE_SUCCESS)
@@ -3519,9 +3516,10 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
                 }
 
                 unit_log_process_exit(
-                                u, f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
+                                u,
                                 "Control process",
                                 service_exec_command_to_string(s->control_command_id),
+                                f == SERVICE_SUCCESS,
                                 code, status);
 
                 if (s->state != SERVICE_RELOAD && s->result == SERVICE_SUCCESS)
index cc3dc5973d7f9cc5025a7284c612520ebae15364..46fe405a17d7212e12e490065ffc4d122cec9085 100644 (file)
@@ -3014,9 +3014,10 @@ static void socket_sigchld_event(Unit *u, pid_t pid, int code, int status) {
         }
 
         unit_log_process_exit(
-                        u, f == SOCKET_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
+                        u,
                         "Control process",
                         socket_exec_command_to_string(s->control_command_id),
+                        f == SOCKET_SUCCESS,
                         code, status);
 
         if (s->result == SOCKET_SUCCESS)
index 303afc9f35f6f3d0fd118b4b32d95dbf136e5d38..74381c0c95b4481bd7bdd7f189fbb4b700dc7ad6 100644 (file)
@@ -1043,9 +1043,10 @@ static void swap_sigchld_event(Unit *u, pid_t pid, int code, int status) {
         }
 
         unit_log_process_exit(
-                        u, f == SWAP_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
+                        u,
                         "Swap process",
                         swap_exec_command_to_string(s->control_command_id),
+                        f == SWAP_SUCCESS,
                         code, status);
 
         switch (s->state) {
index f46858691b4e313d4ef4aa51d17ce8490b2f961a..31ed473f91057829b77e620a7caa00f6394b5bb3 100644 (file)
@@ -5779,16 +5779,26 @@ void unit_log_skip(Unit *u, const char *result) {
 
 void unit_log_process_exit(
                 Unit *u,
-                int level,
                 const char *kind,
                 const char *command,
+                bool success,
                 int code,
                 int status) {
 
+        int level;
+
         assert(u);
         assert(kind);
 
-        if (code != CLD_EXITED)
+        /* If this is a successful exit, let's log about the exit code on DEBUG level. If this is a failure
+         * and the process exited on its own via exit(), then let's make this a NOTICE, under the assumption
+         * that the service already logged the reason at a higher log level on its own. Otherwise, make it a
+         * WARNING. */
+        if (success)
+                level = LOG_DEBUG;
+        else if (code == CLD_EXITED)
+                level = LOG_NOTICE;
+        else
                 level = LOG_WARNING;
 
         log_struct(level,
index 9ad86fddf6bbffa8be997c43257461c814567f36..4732d72202979548befd5e946b675e12842ba8d6 100644 (file)
@@ -852,7 +852,7 @@ static inline void unit_log_result(Unit *u, bool success, const char *result) {
                 unit_log_failure(u, result);
 }
 
-void unit_log_process_exit(Unit *u, int level, const char *kind, const char *command, int code, int status);
+void unit_log_process_exit(Unit *u, const char *kind, const char *command, bool success, int code, int status);
 
 int unit_exit_status(Unit *u);
 int unit_success_action_exit_status(Unit *u);