main() { while(1) { int pid = fork(); if (pid == 1) { cout << 1; exit(0); } } } |
pid = fork()
fd = accept ( ...) if (pid == 0) handle connect exit |
fd = accept( ..)
pid = fork() if (pid == 0) handle connection exit |
while(1)
pid = fork() fd = accept( ... ) if (fd == 0) handle connection exit |
while(1)
fd = accept( .. ) pid = fork() if (pid > 0) handle connection exit |
main() { sleep(10); // wait 10 seconds. I'm process 6715 fork(); cout << "Yooper Scooper!!\n"; } |