Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

WHY?!

Name: Anonymous 2012-06-13 13:02


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char **argv){

    int cnt = 0;

    for(int i = 0; i < 10; i++){
        fork();
        cnt++;
    }
    printf("PID:  %d\n", getpid());

    printf("Count:  %d\n", cnt);

    return 0;
}


Copy. Paste. Compile. Run.

I only want 10 childprocess. Why is this?

PS: Yes, I'm new to programming

Name: Anonymous 2012-06-13 13:54

>>3

I should rather read man pages (but I get you).

autofacepalm.bmp

[quote=Man Pages]The fork() function shall create a new process. The new process (child process) shall be an exact copy of the  calling  process  (parent  process)[/quote]

What I understand is that childp. make at their time more chilps. How is this not a infinite loop?

And still, I want to create 10 childsp. for any reason. How do?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List