lkml.org 
[lkml]   [1996]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: fork problems (zombie children)
On Mon, 6 May 1996, Thomas Zerucha wrote:

> What am I doing wrong? The following program:
>
> #include <signal.h>
> #include <sys/wait.h>
> main(){
> for(;;) {
> if( !fork() ) {
> exit(0); /* child, exit immediately */
> }
> sleep(1);
> }
> }
>
> when run with PID=8704 creates children that stay undead until the parent
> process terminates, e.g. from "ps -x":
(clip)
>
> I ran out of virtual memory on my 32Mb machine on a different app (lynx)
> after lots of these were created.
>

(I know nothing but) in Linux, like in parenting, you have to wait for
children.

#include<unistd.h>
#include<stdio.h>
#include<sys/types.h>
#include<sys/wait.h>

int main()
{
int fret;
char * argue[2];
char * envirotech[1];
envirotech[0]=NULL;
argue[0]="df";
argue[1]=NULL;

printf(" We are the table dwellers.\n");
if(fret=fork())
{
printf("I am called Knife. My child is Bowl [%d]\n"
"Hmmmm hmmmm (hunting zombies ...)\n",fret);
waitpid(fret, NULL, 0);
printf("Got one. :)\n");
getchar();
}
else {
printf("I am called bowl.<%d>\n", fret);
sleep(5);
}
return 0;
}


__kmb203@psu.edu_________________________Debian__1.1___Linux__1.3.97___
The greatest dangers to liberty lurk in insidious encroachment by men
of zeal, well-meaning but without understanding.
-- Justice Louis D. Brandeis



\
 
 \ /
  Last update: 2005-03-22 13:37    [W:0.209 / U:3.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site