dsb has asked for the wisdom of the Perl Monks concerning the following question:

I believe this one liner brought down the dev server at my job. I ran it, and about 10 seconds later the system abended.
$ perl -e "while ( ++$i ) { $a[$i] = fork; }"
I killed it after it ran for only about 2 seconds. Did no good apparently. The system is still down.

- kel -

Replies are listed 'Best First'.
Re: One Liner
by extremely (Priest) on Feb 15, 2001 at 02:40 UTC
    Heh, yeah, that would do on many a system. Once your sysadmin gets it back up, you might recommend that they implement some sort of rational maximum processes per user limit and maybe a maximum memory limit.

    --
    $you = new YOU;
    honk() if $you->love(perl)

Re: One Liner
by Yohimbe (Pilgrim) on Feb 15, 2001 at 02:57 UTC
    If this abended your system as a NON-root user, then a) your system does not have well engineered OOM behaviour b) your sysadmins have not set proper ulimits and c) its scary that a fork bomb could fuxor a modern system.

    Update Not many modern systems call it abend any more either, so my previous comment may be redundant RH is fairly "modern", so...

    # redhat 6.2 system $ ulimit -a core file size (blocks) 1000000 data seg size (kbytes) unlimited file size (blocks) unlimited max memory size (kbytes) unlimited stack size (kbytes) 8192 cpu time (seconds) unlimited max user processes 2048 pipe size (512 bytes) 8 open files 1024 virtual memory (kbytes) 2105343
    Note that my max user processes is a bit high at 2048. a more normal value for a multi user machine would be < 256, but special circumustances would modify that.
    --
    Jay "Yohimbe" Thorne, alpha geek for UserFriendly
Re: One Liner
by McD (Chaplain) on Feb 15, 2001 at 03:43 UTC
    I did that once to an old Coherent system for fun. while (1) {fork();}

    (Anybody remember Coherent? Linux ate their lunch in the worst way.)

    The system locked up tight as a drum, until I ctrl-c'd out of the starting parent process, at which point it was fine.

    Sending the same bomb into the background, though, killed it dead - couldn't get a kill off at the shell prompt fast enough.

    I just checked the Coherent manual - looks like they didn't have a ulimit implemented.

    (Anybody remember the Coherent manual? Totally comprehensive, it still puts to shame a lot of the stuff published today.)

    Peace,
    -McD

Re: One Liner
by $code or die (Deacon) on Feb 15, 2001 at 04:53 UTC
    Just wondering - why did you type that?

    Maybe we ought to be able to put some restrictions on reading certain threads like one-liner hogs which while highly entertaining and inventive, might lead some people on the path to the dark-side?

    $code or die
    Using perl at
    The Spiders Web
      A friend of mine was actually trying to crash his system at work and asked me for an idea. I gave him that code. I know what you are saying about posting it though. I though about it too late though. And I don't know how to update these posts.

      - kel -

        I don't think its a serious problem, hopefully people will only use these things for "productive purposes". But did you click the link in my earlier post - there are dozens of amazing one liners that will bring down your system in seconds!

        $code or die
        Using perl at
        The Spiders Web