]> granicus.if.org Git - sudo/commitdiff
Use the double fork trick to avoid the monitor process being waited
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 2 Dec 2004 14:53:20 +0000 (14:53 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 2 Dec 2004 14:53:20 +0000 (14:53 +0000)
for by the main program run through sudo.

mon_systrace.c

index 94bd2a453b57b832d316eed69fa07d8602fd7f90..21dce6b4ff25e7c258a6caf6fbe344e6e63c7737 100644 (file)
@@ -125,7 +125,18 @@ systrace_attach(pid)
     case -1:
        error(1, "can't fork");
     case 0:
-       /* tracer */
+       /* tracer, fork again to completely disassociate */
+       switch (fork()) {
+           case -1:
+               warning("can't fork");
+               kill(pid, SIGKILL);
+               _exit(1);
+           case 0:
+               break;
+           default:
+               /* the main sudo process will wait for us */
+               _exit(0);
+       }
        break;
     default:
        /* tracee, sleep until the tracer process wakes us up. */