[PATCH 2/2] Don't try to read the pidfile if passt got a signal

Peter Foley posted 2 patches 1 month, 2 weeks ago
Maintainers: Jason Wang <jasowang@redhat.com>
There is a newer version of this series
[PATCH 2/2] Don't try to read the pidfile if passt got a signal
Posted by Peter Foley 1 month, 2 weeks ago
g_subprocess_get_if_exited returns false if passt was killed by a signal, so we fall through to trying to read the pidfile.

Update the error when passt exits to include the exit code.

Signed-off-by: Peter Foley <pefoley@google.com>
---
 net/passt.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/net/passt.c b/net/passt.c
index b3d4b71314..053c2f5f57 100644
--- a/net/passt.c
+++ b/net/passt.c
@@ -270,8 +270,17 @@ static int net_passt_start_daemon(NetPasstState *s, int sock, Error **errp)
         return -1;
     }
 
-    if (g_subprocess_get_if_exited(daemon) &&
-        g_subprocess_get_exit_status(daemon)) {
+    if (g_subprocess_get_if_exited(daemon)) {
+        gint status = g_subprocess_get_exit_status(daemon);
+        if (status) {
+            error_setg(errp, "Passt exited with code %d", status);
+            return -1;
+      }
+    }
+
+    if (g_subprocess_get_if_signaled(daemon)) {
+        error_setg(errp, "Passt killed with signal %d",
+                   g_subprocess_get_term_sig(daemon));
         return -1;
     }
 

-- 
2.53.0.371.g1d285c8824-goog
Re: [PATCH 2/2] Don't try to read the pidfile if passt got a signal
Posted by Laurent Vivier 1 month, 1 week ago
On 2/23/26 22:52, Peter Foley wrote:
> g_subprocess_get_if_exited returns false if passt was killed by a signal, so we fall through to trying to read the pidfile.
> 
> Update the error when passt exits to include the exit code.
> 
> Signed-off-by: Peter Foley <pefoley@google.com>
> ---
>   net/passt.c | 13 +++++++++++--
>   1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/net/passt.c b/net/passt.c
> index b3d4b71314..053c2f5f57 100644
> --- a/net/passt.c
> +++ b/net/passt.c
> @@ -270,8 +270,17 @@ static int net_passt_start_daemon(NetPasstState *s, int sock, Error **errp)
>           return -1;
>       }
>   
> -    if (g_subprocess_get_if_exited(daemon) &&
> -        g_subprocess_get_exit_status(daemon)) {
> +    if (g_subprocess_get_if_exited(daemon)) {
> +        gint status = g_subprocess_get_exit_status(daemon);
> +        if (status) {
> +            error_setg(errp, "Passt exited with code %d", status);
> +            return -1;
> +      }
        ^^^
Indentation problem (6 spaces instead of 8)

> +    }
> +
> +    if (g_subprocess_get_if_signaled(daemon)) {
> +        error_setg(errp, "Passt killed with signal %d",
> +                   g_subprocess_get_term_sig(daemon));
>           return -1;
>       }
>   
> 

Reviewed-by: Laurent Vivier <lvivier@redhat.com>