[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] Make sure to fork again after setsid() so that child cannot regain CTTY.
# HG changeset patch # User Anthony Liguori <anthony@xxxxxxxxxxxxx> # Node ID c8378d3c3af835a4626c07b9850a4fc19361fec8 # Parent b4dfb49332d2935860ee8ddeebdfffcaef5e800b Make sure to fork again after setsid() so that child cannot regain CTTY. Signed-off-by: Anthony Liguori <aliguori@xxxxxxxxxx> diff -r b4dfb49332d2 -r c8378d3c3af8 tools/console/daemon/utils.c --- a/tools/console/daemon/utils.c Mon Dec 12 11:15:29 2005 +++ b/tools/console/daemon/utils.c Mon Dec 12 15:11:13 2005 @@ -90,6 +90,12 @@ setsid(); + if ((pid = fork()) > 0) { + exit(0); + } else if (pid == -1) { + err(errno, "fork() failed"); + } + /* redirect fd 0,1,2 to /dev/null */ if ((fd = open("/dev/null",O_RDWR)) == -1) { exit(1); diff -r b4dfb49332d2 -r c8378d3c3af8 tools/xenstore/xenstored_core.c --- a/tools/xenstore/xenstored_core.c Mon Dec 12 11:15:29 2005 +++ b/tools/xenstore/xenstored_core.c Mon Dec 12 15:11:13 2005 @@ -1491,6 +1491,13 @@ /* Session leader so ^C doesn't whack us. */ setsid(); + + /* Let session leader exit so child cannot regain CTTY */ + if ((pid = fork()) < 0) + barf_perror("Failed to fork daemon"); + if (pid != 0) + exit(0); + #ifndef TESTING /* Relative paths for socket names */ /* Move off any mount points we might be in. */ chdir("/"); _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |