Ok, we're both wrong. Children do have to be killed individually, and so the
pids do all need to be recorded. However, you cannot have each child record
its own pid to the same pidfile because they may very likely write their pids
on top of one another. The parent must be responsible for writing the pids to
the pidfile and removing them from the pidfile as the children die.

I believe a better solution is for the parent to keep an in-memory table of
children and register the SIGCHILD signal handler so that upon death of the
parent, it goes through the table reaping children before it exits.

My guess is that Paul Stevens' work on dynamic server spawning can be easily
extended to do this, if it doesn't in fact take care of it already.

Aaron


Dan Weber <[EMAIL PROTECTED]> said:
> 
> Sure with threads.  Forked processes no longer require a parent. 
> Writing all the pids is also good habit too. :)
> 
> Dan
> 
> Aaron Stone wrote:
> > Why would the pidfile contain all of the children? The pid should be written
> > before forking so it has the parent pid. Kill it, and the children go, too.
> > 
> > Aaron
> > 
> > 
> > Dan Weber <[EMAIL PROTECTED]> said:
> > 
> >>bah "a+"
> >>
> >>
> >>Dan Weber
> >>
> >>
> >>Dan Weber wrote:
> >>
> >>>btw, you can't use "w" mode because that will just overwrite the pidfile 
> >>>since you need to have it so it stores all the forks, you need to use w+.
> >>>
> >>>Dan Weber
> >>>Aaron Stone wrote:
> >>>
> >>>
> >>>>Yes! Thanks for bring this up. I wrote my own init scripts for 
> >>>>Mandrake and
> >>>>Gentoo and the shutdown procedure is basically 'killall dbmail-blah'.
> >>>>
> >>>>Aaron
> >>>>
> >>>>
> >>>>Dan Weber <[EMAIL PROTECTED]> said:
> >>>>
> >>>>
> >>>>
> >>>>>If its a daemon it needs '-p' for pidfiles.  These debian init 
> >>>>>scripts are atrocious and need to get updated with pidfiles ;)
> >>>>>Below is a somewhat modified version of what I used in siproxd.  Its 
> >>>>>not very complex, just make 'pidfile = optarg' at the 'p' option and 
> >>>>>put it in some header.
> >>>>>
> >>>>>
> >>>>>char *pidfile;
> >>>>>int createpidfile(char* pidfile)
> >>>>>{
> >>>>>   FILE *f = NULL;
> >>>>>   TRACE(TRACE_INFO,"creating PID file [%s]", pidfile);
> >>>>>   if ((f=fopen(pidfile, "w")))
> >>>>>      {
> >>>>>         fprintf(f,"%i\n",(int)getpid());
> >>>>>         fclose(f);
> >>>>>      }
> >>>>>   else
> >>>>>      {
> >>>>>         TRACE(TRACE_ERROR,"couldn't create new PID file: %s", 
> >>>>>strerror(errno));
> >>>>>         return(1);
> >>>>>      }
> >>>>>   return(0);
> >>>>>}
> >>>>>
> >>>>>Dan
> >>>>>
> >>>>>
> >>>>>Aaron Stone wrote:
> >>>>>
> >>>>>
> >>>>>>How about this set of command line options across the board...
> >>>>>>
> >>>>>>Common options for all DBMail utilities:
> >>>>>>    -f file   specify an alternative config file
> >>>>>>    -q        quietly skip interactive prompts
> >>>>>>    -n        show the intended action but do not perform it, no to all
> >>>>>>    -y        perform all proposed actions, as though yes to all
> >>>>>>    -v        verbose details
> >>>>>>    -V        show the version
> >>>>>>    -h        show this help message
> >>>>>>
> >>>>>>One option that I'd like to have on the command line for the daemons 
> >>>>>>is a
> >>>>>>no-daemonize / no-fork option. This would be a great benefit for 
> >>>>>>lots of
> >>>>>>debugging and testing situations. Would overloading the meaning of 
> >>>>>>'-n' work?
> >>>>>>
> >>>>>>Thoughts, questions, comments?
> >>>>>>
> >>>>>>Aaron
> >>>>>>_______________________________________________
> >>>>>>Dbmail-dev mailing list
> >>>>>>[email protected]
> >>>>>>http://twister.fastxs.net/mailman/listinfo/dbmail-dev
> >>>>>>
> >>>>>
> >>>>>
> >>>>>--------------enigA76E70A2620D0BAB39B88C67
> >>>>>Content-Type: application/pgp-signature; name="signature.asc"
> >>>>>Content-Description: OpenPGP digital signature
> >>>>>Content-Disposition: attachment; filename="signature.asc"
> >>>>>
> >>>>>-----BEGIN PGP SIGNATURE-----
> >>>>>Version: GnuPG v1.2.4 (GNU/Linux)
> >>>>>Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
> >>>>>
> >>>>>iD8DBQFA7EZZF6i3K/AxoQERAp8hAKCvAo1x5Ka/FG5HIGHJYUdZHDuLIgCgokVZ
> >>>>>XjwSALw8bUZECJPFrQaD6us=
> >>>>>=Y1pt
> >>>>>-----END PGP SIGNATURE-----
> >>>>>
> >>>>>--------------enigA76E70A2620D0BAB39B88C67--
> >>>>>
> >>>>>--===============0984879432==
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>>------------------------------------------------------------------------
> >>>
> >>>_______________________________________________
> >>>Dbmail-dev mailing list
> >>>[email protected]
> >>>http://twister.fastxs.net/mailman/listinfo/dbmail-dev
> >>
> >>
> >>--------------enig77C70C80A58D5CEEC45596DC
> >>Content-Type: application/pgp-signature; name="signature.asc"
> >>Content-Description: OpenPGP digital signature
> >>Content-Disposition: attachment; filename="signature.asc"
> >>
> >>-----BEGIN PGP SIGNATURE-----
> >>Version: GnuPG v1.2.4 (GNU/Linux)
> >>Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
> >>
> >>iD8DBQFA7KknF6i3K/AxoQERAuAVAKDQSZouJXJwyitgVNvQIN1U3qTimgCgriWD
> >>nxgtPQewM5xMsP1/wzbScvw=
> >>=b9Dw
> >>-----END PGP SIGNATURE-----
> >>
> >>--------------enig77C70C80A58D5CEEC45596DC--
> >>
> >>--===============0154159932==
> > 
> > 
> > 
> > 
> 
> 
> --------------enig76266D7CA9CB7D4312ADA8DC
> Content-Type: application/pgp-signature; name="signature.asc"
> Content-Description: OpenPGP digital signature
> Content-Disposition: attachment; filename="signature.asc"
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.4 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
> 
> iD8DBQFA7MTAF6i3K/AxoQERApvsAKC4mmciEFw62neEOKzZ2xbcsdDWSwCg21C4
> UCIMeyeDQZIlTdkVg0ou/oo=
> =ZAJ6
> -----END PGP SIGNATURE-----
> 
> --------------enig76266D7CA9CB7D4312ADA8DC--
> 
> --===============2044374922==



-- 



Reply via email to