From aa69e853c06e266e8f4c11bd4b84562c661e9041 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Thu, 10 Mar 2022 14:03:22 -0800 Subject: [PATCH] `SystemdLifecycle` logging "Operation not permitted" calling `sd_notify(3)` during startup --- .../main/java/hudson/lifecycle/SystemdLifecycle.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/hudson/lifecycle/SystemdLifecycle.java b/core/src/main/java/hudson/lifecycle/SystemdLifecycle.java index 31afd55ccf..8d6b684cfe 100644 --- a/core/src/main/java/hudson/lifecycle/SystemdLifecycle.java +++ b/core/src/main/java/hudson/lifecycle/SystemdLifecycle.java @@ -1,6 +1,5 @@ package hudson.lifecycle; -import com.sun.jna.LastErrorException; import com.sun.jna.Library; import com.sun.jna.Native; import edu.umd.cs.findbugs.annotations.CheckForNull; @@ -26,7 +25,7 @@ public class SystemdLifecycle extends ExitLifecycle { interface Systemd extends Library { Systemd INSTANCE = Native.load("systemd", Systemd.class); - int sd_notify(int unset_environment, String state) throws LastErrorException; + int sd_notify(int unset_environment, String state); } @Override @@ -60,10 +59,9 @@ public class SystemdLifecycle extends ExitLifecycle { } private static synchronized void notify(String message) { - try { - Systemd.INSTANCE.sd_notify(0, message); - } catch (LastErrorException e) { - LOGGER.log(Level.WARNING, null, e); + int rv = Systemd.INSTANCE.sd_notify(0, message); + if (rv < 0) { + LOGGER.log(Level.WARNING, "sd_notify(3) returned {0}", rv); } } }