Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Forking a bunch of processes...

351 views
Skip to first unread message

Daniel M. Rosenberg

unread,
Mar 31, 1993, 7:46:21 PM3/31/93
to
Hi folks --
I'm trying to write a perl script that will fork off a whole
bunch of processes -- without filling up the process table.

o I can't wait for the processes to end -- some might not until
I kill them.

o Most processes will end quickly.

o I don't want to fill up the process table with zombies.

o I'll be forking around 200 processes, of which up to 30 might
hang, worst case.

In case you haven't guessed, this is a cron job to test machines to make
sure they're up.

The examples on p. 216 of the book needs a wait to prevent zombies.
I can't really wait -- I need to check everything, even if some processes
in the middle hang.

Execs seem to take up a lot of resources, if I just re-execute the script.

Has anyone done this before?


---
# Daniel M. Rosenberg Daniel.R...@Corp.Sun.COM +1 415 688 9580
# Opinions expressed above aren't Sun's.

Larry Wall

unread,
Apr 7, 1993, 4:43:10 PM4/7/93
to
In article <1pde0t...@jethro.Corp.Sun.COM> d...@medicated.Corp.Sun.COM writes:
: The examples on p. 216 of the book needs a wait to prevent zombies.

: I can't really wait -- I need to check everything, even if some processes
: in the middle hang.

On some systems doing a $SIG{CHLD} = IGNORE seems to help in the prevention
of zombies.

Larry

Roy Johnson

unread,
Apr 13, 1993, 11:59:07 AM4/13/93
to
lw...@netlabs.com (Larry Wall) writes:
On some systems doing a $SIG{CHLD} = IGNORE seems to help in the prevention
of zombies.

Larry

The book indicates that CHLD and IGNORE above should be string values.
It seems to work both ways. Why? (Not a complaint).
--
Roy Johnson Shell Development Company (but speaking for myself)
"Nothing says 'I love my country' like higher taxes." -- Ed Ipser

Mike Stok

unread,
Apr 13, 1993, 12:49:14 PM4/13/93
to
In article <RJOHNSON.93...@conus.shell.com> rjoh...@shell.com (Roy Johnson) writes:
>
>The book indicates that CHLD and IGNORE above should be string values.
>It seems to work both ways. Why? (Not a complaint).

check out the index entry for unquoted strings...

To quote (without permission) from the book

A word that doesn't have any other interpretation in the grammar
will be treated as if it had single quotes around it.

Mike
--
The "usual disclaimers" apply. | Meiko
Mike Stok | Reservoir Place
mi...@meiko.com | 1601 Trapelo Road
Meiko tel: (617) 890 7676 | Waltham, MA 02154

Randal L. Schwartz

unread,
Apr 13, 1993, 5:56:08 AM4/13/93
to
>>>>> In article <RJOHNSON.93...@conus.shell.com>, rjoh...@shell.com (Roy Johnson) writes:
Roy> The book indicates that CHLD and IGNORE above should be string values.
Roy> It seems to work both ways. Why? (Not a complaint).

"Perl poetry mode", or "bare word mode" depending on how formal you
want to get about it.

A single C symbol without quotes that is not a keyword in a location
that can use a quoted string is automatically promoted to a quoted
string.

from the debugger:
DB<1> print join("X",foo,bar);
fooXbar
DB<2> print join(_,unpack(C99,A_Very_Odd_Example));
65_95_86_101_114_121_95_79_100_100_95_69_120_97_109_112_108_101

One good use of this minor syntactic sugar is to pass filehandles
without having to quote them:

sub say {
local($filehandle,$what) = @_;
print $filehandle $what;
}

&say(STDOUT,"Hello, world!\n");

Without bare word mode, we'd have to say:

&say("STDOUT","Hello, world!\n");

The real reason this was added was to support better Perl poetry.
(See the Camel book for an example of poetry, but there were many
others...) Right, Sharon?

print join($",Just,another,Perl,hacker),qq,\,,
--
Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
mer...@ora.com (semi-permanent) mer...@kandinsky.intel.com (temp)
factoid: "Portland, Oregon, home of the California Raisins and Lone-Star Beer!"

Sharon Hopkins

unread,
Apr 16, 1993, 1:48:49 PM4/16/93
to
In article <MERLYN.93A...@kandinsky.intel.com> mer...@ora.com writes:
>One good use of this minor syntactic sugar is to pass filehandles
>without having to quote them:
>
>sub say {
> local($filehandle,$what) = @_;
> print $filehandle $what;
>}
>
>&say(STDOUT,"Hello, world!\n");
>
>Without bare word mode, we'd have to say:
>
>&say("STDOUT","Hello, world!\n");
>
>The real reason this was added was to support better Perl poetry.
>(See the Camel book for an example of poetry, but there were many
>others...) Right, Sharon?
>
>print join($",Just,another,Perl,hacker),qq,\,,

Yup. :-) There was even a paper on Perl poetry at the 1992 Winter Usenix
conference, with examples by myself, Larry Wall, and Craig Counterman,
plus a FORTRAN example by David Mar. Michael Cook has also written some
Perl poetry, and received his due reward.

For those who are new to the concept of programming-language poetry, I'm
including my "listen" poem (my first perl poem). Right now I'm mostly
waiting for Perl 5, which will have a few neat new things for me to try...

(Unless I can come up with something clever before then. :-)


print "Just another Perl (and REXX!) poet,"

--Sharon

--------------------------------------------------------------------------
#!/usr/bin/perl

APPEAL:

listen (please, please);

open yourself, wide,
join (you, me),
connect (us,together),

tell me.

do something if distressed;

@dawn, dance;
@evening, sing;
read (books,poems,stories) until peaceful;
study if able;

write me if-you-please;

sort your feelings, reset goals, seek (friends, family, anyone);

do not die (like this)
if sin abounds;


keys (hidden), open locks, doors, tell secrets;
do not, I-beg-you, close them, yet.

accept (yourself, changes),
bind (grief, despair);

require truth, goodness if-you-will, each moment;


select (always), length(of-days)

# Sharon Hopkins, Feb. 21, 1991
# listen (a perl poem)
# {for jimmy (and tom)}

John Nall

unread,
Apr 16, 1993, 3:10:04 PM4/16/93
to
In article <1993Apr16....@netlabs.com> sha...@netlabs.com (Sharon Hopkins) writes:

( ... good stuff about perl poetry deleted ... )

>For those who are new to the concept of programming-language poetry, I'm
>including my "listen" poem (my first perl poem).

Hah! A likely story! Come clean, Sharon, and admit you wrote BLACK PERL! :-)


John

--
John W. Nall | Supercomputer Computations Research Institute
na...@mailer.scri.fsu.edu | Florida State University, Tallahassee, Florida
"You gotta know when to hold 'em/know when to fold 'em/
"know when to walk away/and know when to run..."

Sharon Hopkins

unread,
Apr 16, 1993, 7:37:42 PM4/16/93
to
In article <12...@sun13.scri.fsu.edu> na...@ibm12.scri.fsu.edu (John Nall) writes:
>In article <1993Apr16....@netlabs.com> sha...@netlabs.com (Sharon Hopkins) writes:
>
>>For those who are new to the concept of programming-language poetry, I'm
>>including my "listen" poem (my first perl poem).
>
>Hah! A likely story! Come clean, Sharon, and admit you wrote BLACK PERL! :-)

It's a base canard!!!

Ok, I can't deny *all* knowledge of the genesis of the "Black Perl" poem,
but my mind isn't *nearly* twisty enough to have been the creator.

You see, "Black Perl" was written BEFORE poetry optimizations were added
to Perl; look closely and you'll see that the bare-words trick isn't
used *at all* in the "Black Perl" poem! Clearly an Evil Genious was at
work. (Know any?)

:-)

Hmm, speaking of smileys, this is my favorite line of perl poetry:

getpeername(s) -- cute ones! :-) :-)) & sort carefully

Bonus points to the first person (other than Mark, Tom, Larry, or Randal)
who knows why that works...


print "Not just another Black Perl poet,"

--Sharon

Erik Johansen (System programmer)

unread,
Apr 17, 1993, 9:23:44 AM4/17/93
to
sha...@netlabs.com (Sharon Hopkins) writes:

>Hmm, speaking of smileys, this is my favorite line of perl poetry:

> getpeername(s) -- cute ones! :-) :-)) & sort carefully

>Bonus points to the first person (other than Mark, Tom, Larry, or Randal)
>who knows why that works...

That's really cute. It works because the s)...)...) substitute
takes the cute ones! and tries to replace them with smileys.....

Of course the sort does not do very much since it has nothing to sort.

Seems like Perl does not check that &carefully exists...


--

Erik Johansen

----

Sharon Hopkins

unread,
Apr 19, 1993, 4:04:55 PM4/19/93
to

You're right on the substitution, but I fooled you with the "&":
it's actually a bitwise AND, not a subroutine call, so the sort really
is sorting "carefully".

One of the fun things to do with perl poetry is to go ahead and use
reserved words (and punctuation) whenever you can fit some in,
just to keep it looking like perl.

That line could have been something like:

getpeername() & laugh & smile & joke & sort lookswise carefully

if I wanted to get fancy. :-)

--Sharon

0 new messages