Hi Florian,

> 
> So i would whish flow-capture to write the pid file once setup of the
> program has succeeded down to beeing able to receive flows.
> 

Please try the attached patch. Be careful though, it's for flow-tools 0.68.

Cheers,
Radu Spineanu
diff -Naur flow-tools-0.68.old/src/flow-capture.c 
flow-tools-0.68/src/flow-capture.c
--- flow-tools-0.68.old/src/flow-capture.c      2007-03-04 15:33:39.970428250 
+0200
+++ flow-tools-0.68/src/flow-capture.c  2007-03-04 15:33:12.000000000 +0200
@@ -443,9 +443,7 @@
     if ((pid = fork()) == -1) {
       fterr_err(1, "fork()");
     } else if (pid) {
-      if (pidfile)
-        write_pidfile(pid, pidfile, ftnet.dst_port);
-      exit (0); /* parent */
+         exit (0); /* parent */
     }
 
     if (!preserve_umask)
@@ -613,6 +611,10 @@
   if (!(ftch = ftchash_new(256, sizeof (struct ftchash_rec_exp), 12, 1)))
     fterr_errx(1, "ftchash_new(): failed");
 
+  /* If we bind to the socket we are running and can write the pidfile */
+  if (pidfile)
+       write_pidfile(getpid(), pidfile, ftnet.dst_port);
+
   /* init msg block */
   ftnet.iov[0].iov_len = sizeof ftpdu.buf;
   ftnet.iov[0].iov_base = (char*)&ftpdu.buf;

Reply via email to