zombies nothing than zombies on a SUN

zombies nothing than zombies on a SUN

Post by Roland Kuff » Fri, 02 Feb 1996 04:00:00





> My development station is a SUN20 running Solaris 2.4 and I am using SUN's
> C compiler.

> I have a daemon that acts as a server for incoming socket connections. The
> parent process forks and waits with accept for a process to connect to the
> parent socket. The child process performs the asked job and terminates
> with an exit(0). This is the normal way it should be done.

> But the child processes do not really quit, they become zombies <defunct>
> and they disapear only if I kill the parent process.

> What can I do to kill the child processes ???

> Can someone help me?


> Thanks in advance.

I forgot to mention that I can not use the normal wait(0) method in a
signal handler which is activated on the signal of the child because in
this case the parent process which waits in in the accept routine will be
interrupted and can not wait anymore for sockets to connect.

You see my problem is not simple at all.

Roland

 
 
 

zombies nothing than zombies on a SUN

Post by Mark Robinso » Fri, 02 Feb 1996 04:00:00



> I forgot to mention that I can not use the normal wait(0) method in a
> signal handler which is activated on the signal of the child because in
> this case the parent process which waits in in the accept routine will be
> interrupted and can not wait anymore for sockets to connect.

> You see my problem is not simple at all.

> Roland

wait3() only waits if there is a child to reap, otherwise it returns
immediately. If you use a buffer with listen (eg listen(sock, 5)), you
shouldn't miss any connections.

Cheers

Mark  
--
Manchester Scientific Instruments   |I'm a slug and I'm alright
Campus Ventures Centre. Uni of M/CR.|That's cos I'm *
Oxford Rd. Manchester. M13 9PL, UK  |It bothers me not that I have no friends
http://www.veryComputer.com/;      |Cos I can have fun with both my ends.

 
 
 

zombies nothing than zombies on a SUN

Post by Roland Kuff » Fri, 02 Feb 1996 04:00:00


My development station is a SUN20 running Solaris 2.4 and I am using SUN's
C compiler.

I have a daemon that acts as a server for incoming socket connections. The
parent process forks and waits with accept for a process to connect to the
parent socket. The child process performs the asked job and terminates
with an exit(0). This is the normal way it should be done.

But the child processes do not really quit, they become zombies <defunct>
and they disapear only if I kill the parent process.

What can I do to kill the child processes ???

Can someone help me?


Thanks in advance.

 
 
 

zombies nothing than zombies on a SUN

Post by Jeffrey L. Thom » Fri, 02 Feb 1996 04:00:00



>But the child processes do not really quit, they become zombies <defunct>
>and they disapear only if I kill the parent process.

void start_bg() {
        int status;

        if (fork()==0) {
                if (fork()==0) {
                        /* all of the sub-program stuff */
                }
                exit(0);
        }
        wait(&status);
        return;

Quote:}

Double forking and waiting for the first child proccess was a trick that
I first learn in perl.

Your milage may vary

Jeff
--
\|||/  _Spike_Man_      ____  | Jeffery L. Thomas  | "The important thing is

  v   first superhero  \ SM / | "This time it will | Curiosity has it own
"more than a cute .sig" \__/  | surely run" - anon | reason for existing."

 
 
 

zombies nothing than zombies on a SUN

Post by Kevin J. Jarn » Sat, 03 Feb 1996 04:00:00


    Roland> But the child processes do not really quit, they become
    Roland> zombies <defunct> and they disapear only if I kill the
    Roland> parent process.

You need to catch SIGCHLD and wait() for the child.  Richard Stevens
has a very good example of a "child reaper" in his "Advanced Programming
in the UNIX Environment" book.

Kevin

--

IDD Information Services  Waltham, MA      | http://www-cs.canisius.edu/~jarnot

 
 
 

zombies nothing than zombies on a SUN

Post by Kari E. Hurt » Tue, 06 Feb 1996 04:00:00


?I forgot to mention that I can not use the normal wait(0) method in a
?signal handler which is activated on the signal of the child because in
?this case the parent process which waits in in the accept routine will be
                                             ^^^^^^^^^^^^^
?interrupted and can not wait anymore for sockets to connect.

?You see my problem is not simple at all.

I suppose that you mean: "in the listen routine"

You of course do something like that:

  do {
        newfd = listen(fd);
        if (-1 == newfd) {
                int err = errno;
                if (EINTR == err) {
                        /* To do tasks what don't have possible to do
                         * in signal handlers:
                         */
                        do_possible_bookkeeping();      
                } else {
                        perror("listen:");
                        break; /* break retry loop */
                }
        }
  } while (-1 == newfd);