[PATCH 1/2] Only kill passt if it wrote a pidfile

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 1/2] Only kill passt if it wrote a pidfile
Posted by Peter Foley 1 month, 2 weeks ago
Avoid killing qemu if passt failed before writing a pidfile.

pid is initialized to 0, so calling pid in this scenario would kill the
entire process group.

Signed-off-by: Peter Foley <pefoley@google.com>
---
 net/passt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/passt.c b/net/passt.c
index 9ed811a514..b3d4b71314 100644
--- a/net/passt.c
+++ b/net/passt.c
@@ -102,7 +102,9 @@ static void net_passt_cleanup(NetClientState *nc)
     }
 #endif
 
-    kill(s->pid, SIGTERM);
+    if (s->pid > 0) {
+        kill(s->pid, SIGTERM);
+    }
     if (g_remove(s->pidfile) != 0) {
         warn_report("Failed to remove passt pidfile %s: %s",
                     s->pidfile, strerror(errno));

-- 
2.53.0.371.g1d285c8824-goog
Re: [PATCH 1/2] Only kill passt if it wrote a pidfile
Posted by Laurent Vivier 1 month, 1 week ago
On 2/23/26 22:52, Peter Foley wrote:
> Avoid killing qemu if passt failed before writing a pidfile.
> 
> pid is initialized to 0, so calling pid in this scenario would kill the
> entire process group.
> 
> Signed-off-by: Peter Foley <pefoley@google.com>
> ---
>   net/passt.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/net/passt.c b/net/passt.c
> index 9ed811a514..b3d4b71314 100644
> --- a/net/passt.c
> +++ b/net/passt.c
> @@ -102,7 +102,9 @@ static void net_passt_cleanup(NetClientState *nc)
>       }
>   #endif
>   
> -    kill(s->pid, SIGTERM);
> +    if (s->pid > 0) {
> +        kill(s->pid, SIGTERM);
> +    }
>       if (g_remove(s->pidfile) != 0) {
>           warn_report("Failed to remove passt pidfile %s: %s",
>                       s->pidfile, strerror(errno));
> 

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