Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Create zombie intentionally?

Reply
Thread Tools

Create zombie intentionally?

 
 
Ishmael
Guest
Posts: n/a
 
      03-08-2007
Ok, this may sound odd, but I would like to create a zombie process
intentionally. I've been reading the perldoc for perlipc and it seems
like an unhappy marriage between 'alarm' and 'system' should do the
trick, but I haven't been able to get it to work. Can someone give me
a simple (!) example of how to create a zombie (using the alarm/
system combo - or even better, using fork and exec)? Thanks for you
help!

By the way, here's what I've been trying (unsuccessfully):

eval {
local $SIG{ALRM} = sub {die "system call killed by alarm"};
alarm 1;
my $cmd = 'perl -e \'while(1) { print "bla\n"; sleep(1); }\'';
# my $cmd = "/bin/tcsh\nwhile 1\necho \"bla\\n\"\nend\n";
print $cmd, "\n";
system($cmd);
alarm 0;
};

 
Reply With Quote
 
 
 
 
Ben Morrow
Guest
Posts: n/a
 
      03-08-2007

Quoth "Ishmael" <(E-Mail Removed)>:
> Ok, this may sound odd, but I would like to create a zombie process
> intentionally. I've been reading the perldoc for perlipc and it seems
> like an unhappy marriage between 'alarm' and 'system' should do the
> trick, but I haven't been able to get it to work. Can someone give me
> a simple (!) example of how to create a zombie (using the alarm/
> system combo - or even better, using fork and exec)? Thanks for you
> help!


use POSIX qw/_exit/;

$SIG{CHLD} = 'DEFAULT';
# just to make sure. the important thing is that is shouldn't be
# 'IGNORE', or zombies may be automatically reaped.

my $kid = fork;
defined $kid or die "fork failed: $!";
$kid or _exit 0;

# now be careful with wait/waitpid

Ben

--
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes, [ Heracles shoots Vulture with arrow. Vulture bursts into ]
'Alcestis') [ flame, and falls out of sight. ] http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
comp.llang.perl.moderated
Guest
Posts: n/a
 
      03-08-2007
On Mar 7, 6:55 pm, "Ishmael" <(E-Mail Removed)> wrote:
> Ok, this may sound odd, but I would like to create a zombie process
> intentionally. I've been reading the perldoc for perlipc and it seems
> like an unhappy marriage between 'alarm' and 'system' should do the
> trick, but I haven't been able to get it to work. Can someone give me
> a simple (!) example of how to create a zombie (using the alarm/
> system combo - or even better, using fork and exec)? Thanks for you
> help!
>
> By the way, here's what I've been trying (unsuccessfully):
>
> eval {
> local $SIG{ALRM} = sub {die "system call killed by alarm"};
> alarm 1;
> my $cmd = 'perl -e \'while(1) { print "bla\n"; sleep(1); }\'';
> # my $cmd = "/bin/tcsh\nwhile 1\necho \"bla\\n\"\nend\n";
> print $cmd, "\n";
> system($cmd);
> alarm 0;
>
> };


quick, dirty, and an expensive 10 sec. shelf life...
but you can kill the abusive parent ASAP and give the
child a decent burial...


perl -le 'if (fork){print $$; 1 while time()-$^T <10} else {exit}'


--
Charles DeRykus

 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      03-08-2007
"Ishmael" <(E-Mail Removed)> wrote:
> Ok, this may sound odd, but I would like to create a zombie process
> intentionally. I've been reading the perldoc for perlipc and it seems
> like an unhappy marriage between 'alarm' and 'system' should do the
> trick, but I haven't been able to get it to work. Can someone give me
> a simple (!) example of how to create a zombie (using the alarm/
> system combo - or even better, using fork and exec)? Thanks for you
> help!


fork or exit; # no error checking done.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
Darren Dunham
Guest
Posts: n/a
 
      03-08-2007
Ishmael <(E-Mail Removed)> wrote:
> Ok, this may sound odd, but I would like to create a zombie process
> intentionally. I've been reading the perldoc for perlipc and it seems
> like an unhappy marriage between 'alarm' and 'system' should do the
> trick, but I haven't been able to get it to work. Can someone give me
> a simple (!) example of how to create a zombie (using the alarm/
> system combo - or even better, using fork and exec)? Thanks for you
> help!


It seems to me like you're overthinking it. Do you understand what a
zombie is?

A zombie is a child that has exited, but the parent has not called
wait() for it.

So you simply need to fork a child, have the child exit, and have the
parent continue to live.

As soon as the parent exits or calls wait(), the child should be reaped.


> By the way, here's what I've been trying (unsuccessfully):


> eval {
> local $SIG{ALRM} = sub {die "system call killed by alarm"};
> alarm 1;
> my $cmd = 'perl -e \'while(1) { print "bla\n"; sleep(1); }\'';
> # my $cmd = "/bin/tcsh\nwhile 1\necho \"bla\\n\"\nend\n";
> print $cmd, "\n";
> system($cmd);
> alarm 0;
> };


system() will always wait for the child process to exit, so it will
never create a (long-term) zombie. You have to call fork() yourself for
that to happen.

--
Darren Dunham (E-Mail Removed)
Senior Technical Consultant TAOS http://www.taos.com/
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
 
Reply With Quote
 
Bart Lateur
Guest
Posts: n/a
 
      03-08-2007
(E-Mail Removed) wrote:

>fork or exit; # no error checking done.


Nah, both parent and child will immediately exit.

The idea of a zombie is that the child process quits, the parent goes
on, and doesn't "wait". So, I'd try this:

sleep 10 if fork;

--
Bart.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Zombie Honeymoon Fran DVD Video 0 07-29-2005 05:04 AM
How to kill a zombie ssh session on a router. AM Cisco 2 01-12-2005 03:17 PM
DVD Verdict reviews: ZOMBIE PLANET, STATESIDE, BROKEN WINGS, and more! DVD Verdict DVD Video 0 11-11-2004 10:10 AM
Look UK eBayers, going dirt cheap, Zombie (aka Zombie Flesh Eaters) R1 Peter Row DVD Video 0 08-27-2004 03:02 PM
plouk zombie plouk zombie serge.john.swilting Perl Misc 1 08-20-2003 06:43 AM



Advertisments