[PATCH] system/exit-with-parent.c: Close the file descriptor before exit

Richard W.M. Jones posted 1 patch 1 week, 4 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260518184333.8505-1-rjones@redhat.com
system/exit-with-parent.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] system/exit-with-parent.c: Close the file descriptor before exit
Posted by Richard W.M. Jones 1 week, 4 days ago
On macOS we leak the open file descriptor in the background thread.
Close it before returning.

Link: https://lists.gnu.org/archive/html/qemu-devel/2026-05/msg04286.html
Reported-by: Thomas Huth
Fixes: commit 886898baad ("Implement -run-with exit-with-parent=on")
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
---
 system/exit-with-parent.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/system/exit-with-parent.c b/system/exit-with-parent.c
index df65d2231a..d236944572 100644
--- a/system/exit-with-parent.c
+++ b/system/exit-with-parent.c
@@ -109,6 +109,7 @@ exit_with_parent_loop(void *vp)
         /* Behave like Linux and FreeBSD above, as if SIGTERM was sent */
         qemu_system_killed(SIGTERM, ppid);
     }
+    close(fd);
 
     return NULL;
 }
-- 
2.53.0
Re: [PATCH] system/exit-with-parent.c: Close the file descriptor before exit
Posted by Thomas Huth 1 week, 4 days ago
On 18/05/2026 20.43, Richard W.M. Jones wrote:
> On macOS we leak the open file descriptor in the background thread.
> Close it before returning.
> 
> Link: https://lists.gnu.org/archive/html/qemu-devel/2026-05/msg04286.html
> Reported-by: Thomas Huth
> Fixes: commit 886898baad ("Implement -run-with exit-with-parent=on")
> Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
> ---
>   system/exit-with-parent.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/system/exit-with-parent.c b/system/exit-with-parent.c
> index df65d2231a..d236944572 100644
> --- a/system/exit-with-parent.c
> +++ b/system/exit-with-parent.c
> @@ -109,6 +109,7 @@ exit_with_parent_loop(void *vp)
>           /* Behave like Linux and FreeBSD above, as if SIGTERM was sent */
>           qemu_system_killed(SIGTERM, ppid);
>       }
> +    close(fd);
>   
>       return NULL;
>   }

Reviewed-by: Thomas Huth <thuth@redhat.com>