My program dies.


K

krivenok.dmitry

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?
 
Ad

Advertisements

P

Paul Pluzhnikov

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,
 
K

Krivenok Dmitry

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

Advertisements

A

anno4000

Krivenok Dmitry said:
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
 
Ad

Advertisements


Top