From jhoblitt at mysun.com Mon Oct 15 21:02:58 2001 From: jhoblitt at mysun.com (josh hoblitt) Date: Wed Aug 4 00:05:24 2004 Subject: Cleaning up after your children Message-ID: <28ede29879.2987928ede@mysun.com> I'm working on a small preforking (like apache) webserver. I'd like to have the children pass information about their present status to the parent. After having trouble getting IO::Select to work correctly I posted to begginers@perl. With some help I'v gotten it atleast somewhat working with examples from the perl cookbook and perlipc thrown together. I'm still having two difficulties... one the only way I can seem to avoid having some defunct children is to set $SIG{CHLD} = 'IGNORE'. I do not want to do this because I'm dependant on the signal to know when to fork a replacement child. Is there someway to guarentee trapping signals and they won't be ignored while dealing with a prevous signal. And two the IO::Select method can_read never seems to block even after all the children have died and closed they're end of the pipe it stills returns a list of all the added handles. To recreate the defunct children just swap the sig chld handlers in this code blurb. #!/usr/bin/perl -w use IO::Handle; use IO::Select; use POSIX ":sys_wait_h"; use strict; our $select = IO::Select->new(); sub REAPER { $SIG{CHLD} = \&REAPER; my $pid = wait; print "$pid died\n"; } #$SIG{CHLD} = \&REAPER; $SIG{CHLD} = 'IGNORE'; for (1 .. 30) { make_new_child(); } while (1) { my @tmp = $select->can_read; print @tmp; my $line; foreach my $key (@tmp) { if (defined($line = <$key>)) { print $line; } else { # close ($key); } } } sub make_new_child { my $pid; my $sigset; my $parent_rdr = new IO::Handle; my $child_wtr = new IO::Handle; pipe($parent_rdr, $child_wtr); if (!defined ($pid = fork)) { die "Unable to fork: $!\n"; } if ($pid) { close($child_wtr); $select->add($parent_rdr); # waitpid( -1, &WNOHANG ); } else { close($parent_rdr); print $child_wtr "this is a test\n"; sleep 2; print $child_wtr "this is a test too\n"; sleep 2; print $child_wtr ""; close ($child_wtr); die; } } -Joshua Hoblitt -- jhoblitt@mysun.com TIMTOWTDI From merlyn at stonehenge.com Tue Oct 16 03:12:35 2001 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: Wed Aug 4 00:05:24 2004 Subject: Cleaning up after your children In-Reply-To: <28ede29879.2987928ede@mysun.com> References: <28ede29879.2987928ede@mysun.com> Message-ID: >>>>> "josh" == josh hoblitt writes: josh> I'm working on a small preforking (like apache) webserver. I'd like to josh> have the children pass information about their present status to the josh> parent. After having trouble getting IO::Select to work correctly I josh> posted to begginers@perl. With some help I'v gotten it atleast somewhat josh> working with examples from the perl cookbook and perlipc thrown josh> together. I'm still having two difficulties... one the only way I can josh> seem to avoid having some defunct children is to set $SIG{CHLD} = josh> 'IGNORE'. I do not want to do this because I'm dependant on the signal josh> to know when to fork a replacement child. Have you looked at the columns I pointed you at? josh> Is there someway to guarentee josh> trapping signals and they won't be ignored while dealing with a prevous josh> signal. No. And remember what I already told you (I think)... if two kids both die at the same time, you'll get one SIGCHLD, not two. Look at the columns. Read the associated explanatory text. Don't reinvent the wheel until you've studied prior art. See col15 in for example. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! TIMTOWTDI From merlyn at stonehenge.com Tue Oct 16 03:18:15 2001 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: Wed Aug 4 00:05:24 2004 Subject: Suggestion for possible social get-together Message-ID: I'll be out of town for 4 weeks starting next week, but I return Thanksgiving week. I wonder if we can pull off a social meeting on either nov 19 or nov 20. Is there anyone interested in that? Some centrally located pub, like a McM or perhaps whatever that microbrewery in the Pe(a)rl district that *used* to be Portland Brewing (is that Rogue now?). The real reason is that I want to have some friends to celebrate my 40th birthday slightly early (it's on Thanksgiving). So, can we come out to play? -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! TIMTOWTDI From jhoblitt at mysun.com Tue Oct 16 04:24:25 2001 From: jhoblitt at mysun.com (josh hoblitt) Date: Wed Aug 4 00:05:24 2004 Subject: Cleaning up after your children Message-ID: <299a22b702.2b702299a2@mysun.com> > Have you looked at the columns I pointed you at? No, but then again I haven't recieve the "point" yet. If you sent it to begin. perl without cc'ing to me the last digest I recieved was at 12:50am and doesn't haven't anything from you in it. :) I will keep any eye out for it though. I did take a look at your LinuxMag Columns. Col15 "Getting your kids to do the work (Aug 00)" is pretty close to what I'm trying to do in terms of child management. Am I understanding correctly to state that it's pretty much impossible to avoid defunct children in some situations? I was thinking that I was just missing something. If thats true I will go ahead and deal with killing defunct children. > Don't reinvent the wheel until you've studied prior art. As for re-inventing the wheel thats what makes it fun. The whole point of this is to learn (it's not for work) so I'm doing whole thing while being limited to core modules. Although writing my own http/1.1 implimentation from scratch was kinda painful. So what if my wheels end up being square :) Ps. It was nice meeting you at the p6 talk and think the Stonehenge sponsorship was a great gift to the community (even if the tee-shirts were too small). Never the less, my thanks! -Joshua Hoblitt TIMTOWTDI From gene at ology.net Tue Oct 16 04:40:27 2001 From: gene at ology.net (Gene Boggs) Date: Wed Aug 4 00:05:24 2004 Subject: Suggestion for possible social get-together In-Reply-To: Message-ID: Count me in. :) -gb Gene Boggs Software Engineer at-large ___________________________ Randal L. Schwartz (16 Oct 2001): >The real reason is that I want to have some friends to celebrate my >40th birthday slightly early (it's on Thanksgiving). So, can we come >out to play? TIMTOWTDI From mikeraz at patch.com Tue Oct 16 08:19:51 2001 From: mikeraz at patch.com (mikeraz@patch.com) Date: Wed Aug 4 00:05:24 2004 Subject: Suggestion for possible social get-together In-Reply-To: ; from merlyn@stonehenge.com on Tue, Oct 16, 2001 at 01:18:15AM -0700 References: Message-ID: <20011016061951.B10364@patch.com> On Tue, Oct 16, 2001 at 01:18:15AM -0700, Randal L. Schwartz typed: > I wonder if we can pull off a social meeting on either nov 19 or nov > 20. Is there anyone interested in that? Some centrally located pub, > like a McM or perhaps whatever that microbrewery in the Pe(a)rl > district that *used* to be Portland Brewing (is that Rogue now?). That is Rogue now. They are very amenable to groups and have a wide variety of beer. All Rogue beer, but a large stylistic variety just the same. -- Michael Rasmussen aka mikeraz Be appropriate && Follow your curiosity "They that give up essential liberty to obtain temporary safety, deserve neither liberty nor safety." -- Benjamin Franklin But keep in mind: To a Californian, the basic difference between the people and the pigeons in New York is that the pigeons don't shit on each other. -- From "East vs. West: The War Between the Coasts -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available Url : http://mail.pm.org/archives/pdx-pm-list/attachments/20011016/c32608af/attachment.bin From masque at mindless.com Fri Oct 19 21:58:33 2001 From: masque at mindless.com (Masque) Date: Wed Aug 4 00:05:24 2004 Subject: Suggestion for possible social get-together In-Reply-To: Message-ID: <596849E0-C506-11D5-9838-003065D61560@mindless.com> That get-together sounds fantastic. I would love to attend, however... ...I have some sad and exciting news. After 20 years in the Portland area, I am moving. I have accepted a job in South Carolina and I will be gone as of the fifth of November. It has been a great honor to lead this bunch and I look forward to returning to visit. I'll be around for the mean time; after that, well, reach me the same way you always do. Ain't the 'net grand? Toss one back for me, boys and girls. I'll see you all later. Paul Blair - El Honcho Cabesa, PDX.pm TIMTOWTDI