daemonize(): child waits for parent to finish now
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Mon, 5 Jan 2004 22:15:03 +0000 (22:15 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Mon, 5 Jan 2004 22:15:03 +0000 (22:15 +0000)
use fd3 for synchronisation
enable fork on default

git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@547 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/src/rpm-fake-resolver.c

index 4e5bc30..7fb15f7 100644 (file)
@@ -182,7 +182,7 @@ run()
   uint8_t      c;
 
   while (true) {
-    Ewrite(2, ".", 1);
+    Ewrite(3, ".", 1);
     Eread (0, &c,  sizeof c);
     switch (c) {
       case 'P' :  do_getpwnam(); break;
@@ -198,7 +198,13 @@ run()
 static void
 daemonize(struct ArgInfo const UNUSED * args, int pid_fd)
 {
-  pid_t                pid = Efork();
+  int          p[2];
+  pid_t                pid;
+  char         c;
+  
+  Epipe(p);
+  pid = Efork();
+  
   if (pid!=0) {
     if (pid_fd!=-1) {
       char     buf[sizeof(id_t)*3 + 2];
@@ -210,6 +216,9 @@ daemonize(struct ArgInfo const UNUSED * args, int pid_fd)
     }
     _exit(0);
   }
+  Eclose(p[1]);
+  read(p[0], &c, 1);
+  Eclose(p[0]);
 }
 
 int main(int argc, char * argv[])
@@ -218,7 +227,7 @@ int main(int argc, char * argv[])
     .ctx      = VC_RANDCTX,
     .uid      = 99,
     .gid      = 99,
-    .do_fork  = false,
+    .do_fork  = true,
     .pid_file = 0,
     .chroot   = 0
   };