Skip to contentSkip to conversation

libxl: Call setsid(2) before exec'ing device model

PATCH In review Jim Fehlig 2 participants 2 messages Mar 8, 2011 – Mar 10, 2011

lore
Share & tools
lore

Jim Fehlig

author
#0 lore raw

PATCH 1/1 libxl: Call setsid(2) before exec'ing device model

While developing libvirt libxl driver I noticed that terminating the client causes any qemu-dm processes indirectly started by the client to also terminate. Calling setsid(2) before exec'ing qemu-dm resolves the issue but I'm not quite sure about the placement of the setsid() call or any unforeseen side-affects of its use. Comments welcome.

Regards,
Jim

# HG changeset patch
# User Jim Fehlig <[email protected]>
# Date 1299552244 25200
# Node ID 94fde77241912b634b492979ffc8cdb9516d6136 # Parent d8a65dd15d703ba302b0141e9ffe447ff1cd2a64 Call setsid(2) before exec'ing device model

While doing development on libvirt libxenlight driver I noticed that terminating a libxenlight client causes any qemu-dm processes that were indirectly created by the client to also terminate. Calling setsid(2) before exec'ing qemu-dm resolves the issue.

tools/libxl/libxl_dm.c +1 -0
diff -r d8a65dd15d70 -r 94fde7724191 tools/libxl/libxl_dm.c
@@ -681,6 +681,7 @@
     if (rc < 0)
         goto out_close;
     if (!rc) { /* inner child */
+        setsid();
         libxl__exec(null, logfile_w, logfile_w,
                    libxl__abs_path(&gc, info->device_model, libxl_libexec_path()),
                    args);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Jim Fehlig writes ("[Xen-devel] [PATCH] libxl: Call setsid(2) before exec'ing device model"):

Quoted 5 lines

While developing libvirt libxl driver I noticed that terminating the client causes any qemu-dm processes indirectly started by the client to also terminate. Calling setsid(2) before exec'ing qemu-dm resolves the issue but I'm not quite sure about the placement of the setsid() call or any unforeseen side-affects of its use. Comments welcome.

Thanks, I think your patch is correct, and has the setsid in the right place. libxl_spawn_spawn was another possibility but I think it's probably better to do it in the caller.

Applied (with my and Stefano's ack) to 4.1 and unstable.

Ian.