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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Linux: using "clone3" and "waitid" 0
Communicating between processes 0
process dies on MAC .. 0
Adding adressing of IPv6 to program 1
C pipe 1
Where's my STDOUT? 1
socket script dies 12
Fork Problem 2

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top