WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [BLKTAP] Properly daemonise the blktap co

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [BLKTAP] Properly daemonise the blktap control daemon. Fixes bug #709.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 01 Aug 2006 19:20:21 +0000
Delivery-date: Tue, 01 Aug 2006 12:23:39 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID 6d44ab88d941f335b639f015a4976b07515b9e9c
# Parent  637fa5352fad1490153638e34c4ff0705fb9b8e8
[BLKTAP] Properly daemonise the blktap control daemon. Fixes bug #709.
Signed-off-by: Harry Butterworth <butterwo@xxxxxxxxxx>
---
 tools/blktap/drivers/blktapctrl.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+)

diff -r 637fa5352fad -r 6d44ab88d941 tools/blktap/drivers/blktapctrl.c
--- a/tools/blktap/drivers/blktapctrl.c Mon Jul 31 17:49:36 2006 +0100
+++ b/tools/blktap/drivers/blktapctrl.c Mon Jul 31 18:07:25 2006 +0100
@@ -622,6 +622,38 @@ static void print_drivers(void)
                DPRINTF("Found driver: [%s]\n",dtypes[i]->name);
 } 
 
+/* Stevens. */
+static void daemonize(void)
+{
+       pid_t pid;
+
+       /* Separate from our parent via fork, so init inherits us. */
+       if ((pid = fork()) < 0)
+               DPRINTF("Failed to fork daemon\n");
+       if (pid != 0)
+               exit(0);
+
+       /* Session leader so ^C doesn't whack us. */
+       setsid();
+
+       /* Let session leader exit so child cannot regain CTTY */
+       if ((pid = fork()) < 0)
+               DPRINTF("Failed to fork daemon\n");
+       if (pid != 0)
+               exit(0);
+
+       /* Move off any mount points we might be in. */
+       if (chdir("/") == -1)
+               DPRINTF("Failed to chdir\n");
+
+       /* Discard our parent's old-fashioned umask prejudices. */
+       umask(0);
+
+       close(STDIN_FILENO);
+       close(STDOUT_FILENO);
+       close(STDERR_FILENO);
+}
+
 int main(int argc, char *argv[])
 {
        char *devname;
@@ -633,6 +665,7 @@ int main(int argc, char *argv[])
 
        __init_blkif();
        openlog("BLKTAPCTRL", LOG_CONS|LOG_ODELAY, LOG_DAEMON);
+       daemonize();
 
        print_drivers();
        init_driver_list();

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [BLKTAP] Properly daemonise the blktap control daemon. Fixes bug #709., Xen patchbot-unstable <=