🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #13055

Re: Urgente: matar zombies en servidor concurrente

#13055
From: rvm
Date: Sun, 22 Apr 2001 19:11
41 lines
2317 bytes
El Vie 20 Abr 2001 13:08, cesar m. redondo escribi� lo siguiente:

> Necesito que un servidor concurrente no deje zombies seg�n van
> terminando los procesos hijos que han atendido la petici�n.
> 
> Creo que hay que usar la funci�n signal(SIGCHLD,.........) y waitpid()
> pero no acabo de enterarme, podr�a alguien explicarme como hacerlo.
> Necesito hacerlo en C normal y corriente.

Sacado de info libc y luego buscando wait:

   Here's an example of how to use `waitpid' to get the status from all
child processes that have terminated, without ever waiting.  This
function is designed to be a handler for `SIGCHLD', the signal that
indicates that at least one child process has terminated.

     void
     sigchld_handler (int signum)
     {
       int pid, status, serrno;
       serrno = errno;
       while (1)
         {
           pid = waitpid (WAIT_ANY, &status, WNOHANG);
           if (pid < 0)
             {
               perror ("waitpid");
               break;
             }
           if (pid == 0)
             break;
           notice_termination (pid, status);
         }
       errno = serrno;
     }

-- 
Ricardo Villalba
rvmsoft at jazzfree.com
http://members.xoom.com/rvmsoft/linux
Linux registered user 90754
Technical Details
Message-ID: <1774032.paU67uLZWG@rvmsoft.localdomain>
Path: arc1-ca.pugleaf.net!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!opentransit.net!newsfeed.comtenidos.com!m2newsfeed.uni2.es!m2newsread.uni2.es.POSTED!not-for-mail
References: <3AE01897.93C5854B@mad.tecsidel.es>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,11208b9c47d24792
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2001-04-22 12:12:24 PST
Path: arc1-ca.pugleaf.net!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!opentransit.net!newsfeed.comtenidos.com!m2newsfeed.uni2.es!m2newsread.uni2.es.POSTED!not-for-mail
Message-ID: <1774032.paU67uLZWG@rvmsoft.localdomain>
From: rvm <rvm@linuxfan.com>
Subject: Re: Urgente: matar zombies en servidor concurrente
Newsgroups: es.comp.os.linux.programacion
References: <3AE01897.93C5854B@mad.tecsidel.es>
Lines: 43
User-Agent: RVM-KNode/0.4
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8Bit
Date: Sun, 22 Apr 2001 19:11:52 GMT
NNTP-Posting-Host: 62.37.14.194
X-Complaints-To: abuse@wanadoo.es
X-Trace: m2newsread.uni2.es 987966712 62.37.14.194 (Sun, 22 Apr 2001 21:11:52 MET DST)
NNTP-Posting-Date: Sun, 22 Apr 2001 21:11:52 MET DST
Organization: Servidor Usenet News de Uni2/Wanadoo