]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
notify: don't send EXIT_STATUS= notify message from systemd-notify
authorLennart Poettering <lennart@poettering.net>
Wed, 3 May 2023 12:14:06 +0000 (14:14 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 3 May 2023 16:03:05 +0000 (18:03 +0200)
In 623a00020f116d8e9c70608a9e4f7cc978342441 code was added that our
various programs send a notification message with their exit status on
exit. This is great, but it becomes utterly confusing in systemd-notify,
whose primary purpose is to send such messages after all, and sending an
implicit one in addition to the primary one is particularly confusing,
when debugging things.

Let's hence just drop the implicit message. systemd-notify's exit status
is after all indicative primarily because sd_notify() failed, and hence
it's pretty pointless to then send that fact as another sd_notify()
message.

(Primary reason for this patch is simply that it confused the hell out
of me, when debugging sd_notify() issues)

Follow-up for: 623a00020f116d8e9c70608a9e4f7cc978342441

src/notify/notify.c

index 8489b8387309e36f9d043eaa1d448384f0095798..21e004e4171a10ad77076a60686d4dd433eb8f2d 100644 (file)
@@ -467,6 +467,11 @@ static int run(int argc, char* argv[]) {
                 return log_error_errno(errno, "Failed to execute command line: %s", cmdline);
         }
 
+        /* The DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE() boilerplate will send the exit status via
+         * sd_notify(). Which is normally fine, but very confusing in systemd-notify, whose purpose is to
+         * send user-controllable notification messages, and not implicit ones. Let's turn if off, by
+         * unsetting the $NOTIFY_SOCKET environment variable. */
+        (void) unsetenv("NOTIFY_SOCKET");
         return 0;
 }