report proper pid *after* fork;
authorwenzelm
Fri, 30 Nov 2012 15:05:51 +0100
changeset 50292 45fe12c9788e
parent 50291 674893679352
child 50293 4eea6572896e
report proper pid *after* fork;
Admin/exec_process/exec_process.c
--- a/Admin/exec_process/exec_process.c	Fri Nov 30 10:42:54 2012 +0100
+++ b/Admin/exec_process/exec_process.c	Fri Nov 30 15:05:51 2012 +0100
@@ -28,15 +28,6 @@
   char *script = argv[2];
 
 
-  /* report pid */
-
-  FILE *pid_file;
-  pid_file = fopen(pid_name, "w");
-  if (pid_file == NULL) fail("Cannot open pid file");
-  fprintf(pid_file, "%d", getpid());
-  fclose(pid_file);
-
-
   /* setsid */
 
   if (setsid() == -1) {
@@ -47,6 +38,15 @@
   }
 
 
+  /* report pid */
+
+  FILE *pid_file;
+  pid_file = fopen(pid_name, "w");
+  if (pid_file == NULL) fail("Cannot open pid file");
+  fprintf(pid_file, "%d", getpid());
+  fclose(pid_file);
+
+
   /* exec */
 
   char *cmd_line[4];