My program dies.

Discussion in 'Perl Misc' started by krivenok.dmitry@gmail.com, Jan 15, 2007.

  1. Guest

    Hello All!

    Look at the following pseudo-code:

    ....
    ....
    while(1)
    {
    while( $client = $server->accept )
    {
    next if fork;
    # Child code here
    print "New client\n";

    # Arbitrary perl code (work with Oracle via DBI, logging,
    request processing, etc)

    exit;
    }
    }
    ....
    ....

    As you can see this is a part of TCP server.
    My server dies after some time :(
    I see message about Oracle critical error in my log (this is the last
    message).
    It's very strange because all work with Oracle is performed in _child_
    process!

    I can't understand how can parent process die!
    It may happen only if accept dies, since parent process calls only
    accept and fork
    in its main loop.

    Any ideas?
     
    , Jan 15, 2007
    #1
    1. Advertising

  2. Justin C Guest

    On 2007-01-15, <> wrote:
    > Hello All!
    >
    > Any ideas?


    Yeah, post some code.

    Justin.

    --
    Justin C by the sea.
     
    Justin C, Jan 15, 2007
    #2
    1. Advertising

  3. writes:

    > My server dies after some time :(


    And so it should; it has at least 2 bugs (as posted).

    > I can't understand how can parent process die!


    Hint: what happens when fork fails ?

    The reason fork should fail (given your pseudo-code):
    from "perldoc -f fork":

    If you "fork" without ever waiting on your children, you will
    accumulate zombies.

    Hint: zombies exhaust your per-user process limit, and kernel
    process table.

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.
     
    Paul Pluzhnikov, Jan 16, 2007
    #3
  4. John Bokma Guest

    Paul Pluzhnikov <> wrote:

    > Hint: zombies exhaust your per-user process limit, and kernel
    > process table.


    And they eat the flesh of the living...

    --
    John Experienced Perl programmer: http://castleamber.com/

    Perl help, tutorials, and examples: http://johnbokma.com/perl/
     
    John Bokma, Jan 16, 2007
    #4
  5. John Bokma wrote:
    > Paul Pluzhnikov <> wrote:
    >
    > > Hint: zombies exhaust your per-user process limit, and kernel
    > > process table.


    It's impossible.
    There is SIGCHLD handler in my code.
    ps output doesn't show any zombies.

    >
    > And they eat the flesh of the living...
    >
    > --
    > John Experienced Perl programmer: http://castleamber.com/
    >
    > Perl help, tutorials, and examples: http://johnbokma.com/perl/
     
    Krivenok Dmitry, Jan 16, 2007
    #5
  6. -berlin.de Guest

    Krivenok Dmitry <> wrote in comp.lang.perl.misc:
    >
    > John Bokma wrote:
    > > Paul Pluzhnikov <> wrote:
    > >
    > > > Hint: zombies exhaust your per-user process limit, and kernel
    > > > process table.

    >
    > It's impossible.
    > There is SIGCHLD handler in my code.
    > ps output doesn't show any zombies.


    The show your code (reduced to a minimum that still exhibits the
    problem). Pseudo-code will only give you pseudo-answers.

    Anno
     
    -berlin.de, Jan 16, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dan byers
    Replies:
    1
    Views:
    620
    Hans =?iso-8859-1?Q?J=F8rgen?= Jakobsen
    Mar 6, 2004
  2. Vedran Vukotic

    infinite loop unexpectly dies

    Vedran Vukotic, Mar 2, 2006, in forum: Perl
    Replies:
    0
    Views:
    4,486
    Vedran Vukotic
    Mar 2, 2006
  3. Gumby
    Replies:
    0
    Views:
    497
    Gumby
    Mar 21, 2005
  4. doug

    working c program dies in gdb

    doug, Jan 11, 2007, in forum: C Programming
    Replies:
    2
    Views:
    305
    Yingjian Zhan
    Jan 20, 2007
  5. Christopher M. Lusardi
    Replies:
    3
    Views:
    210
    Alan J. Flavell
    Oct 19, 2003
Loading...

Share This Page