Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I had to come up with something evil yet playful for my 666th post, this is it.

I wish i could have obfuscated it, but alas. And yes, this for *NIX systems only (sorry Darwin users, deprecated confirmed that you are out to). The processes themselves are not really zombie processes - that would be...too evil. >:)

WARNING: don't run this if you don't know how to kill processes! (and don't forget about 'killall' and -9 for the occasional 'Super Zombie'!) ;)

#!/usr/bin/perl -lw use strict; # necromancer my $zombie,$|++,print $/; $SIG{TERM} = sub { hit $zombie; destroy $zombie and return unless $zombie->walks; print qq|"BRAINS!" (|,$zombie->health,' left)'; }; for (1..6) { next if fork; $zombie = raise Zombie; sleep 1 and regen $zombie while 666; } package Zombie; sub raise {print "$$ rises" and bless {hits=>int(rand 5)+2},shift} sub hit {shift->{hits}--} sub walks {shift->{hits} > 1} sub health {$_=shift->{hits};$_ > 1 ?"$_ hits":"$_ hit"} sub regen {shift->{hits}+=3 if int(rand 2)} sub destroy{print qq|"brainsss..." zombie destroyed| and exit}

P.S. deprecated tells me that some Unix systems do not have 'killall', 'pgrep', or 'pkill' handy. He recommends using this for such systems instead:

kill `ps Af | grep perl | grep -v grep | awk '{ print $2 }'`
"sometimes its ps -ef sometimes its ps -xawu and so on. solaris does have pgrep and pkill (but not before 2.6), and many of the BSD's (free open and net) will not have either so the awkkill is necessary."

Thanks deprecated! I named this script zombie.pl, so i would replace 'perl' in the line above with zombie.pl. Don't forget that you can add -9 to 'kill' in the line above as well, but that takes all the fun out! Happy Hunting! ;)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to Zombie Hunter (666th post) by jeffa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-20 01:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found