[lkml]   [1998]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: FreeBSD & Linux [./fork 500 totally hangs my machine 2.1.127]
    In article <>,
    Alan Cox <> wrote:
    >> I did put in one sleep and tested on my macine:
    >> ./fork 100 - 1 sec
    >> ./fork 200 - 2 sec
    >> ./fork 300 - 2 sec
    >> ./fork 400 - 3 sec
    >> ./fork 500 *** My machine totally hangs.
    >> Please Alan, Can you explain this or is this some bug in the kernel??
    >Looks like a 2.1.127 bug - 2.0.36pre16 didnt fall over, 2.1.127 did

    Umm, 2.1.127 doesn't fall over either. But if you run this as root (and
    judging by the number of processes you had, you did), then the program
    is buggy enough that you will essentially kill the system..

    Look at what you do: you do a large number of "fork()" calls, and you
    save the pid's off into an array if they are non-zero. IN PATICULAR:
    when you don't have any more processes left, and fork() returns -1, you
    will save that off as a pid without noticing (the test for the return
    value of fork() is "== 0" for the child, and the parent never tests for

    Now, that part is fine. The part that ISN'T fine is when you try to
    kill off the children: you will do a "kill(-1, SIGKILL)". Oops. You
    just killed off every single process in the system (init, login, etc
    etc), and the system is dead.

    If the same thing doesn't happen under 2.0.36, then the only thing I can
    think of is (a) NR_TASKS is larger? or (b) you didn't run it as root.

    Because your program is _supposed_ to kill the system as it is written.
    Oh, the dangers of running buggy programs as root.

    [ If you run it as a normal user, you'll just be logged out when you
    kill yourself, unless you kill the X server in which case you'll have
    to get in through the network and restart it due to the XFree86
    misfeature we all know and love ]


    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:45    [W:0.019 / U:12.492 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site