[C] How to use fork with C

#include <stdio.h>
#include <unistd.h>
 
 
int main(int argc, char *argv[]) {
 
    char *name = argv[0];
    int child_pid = fork();
    if (child_pid == 0) {
        printf("Child of %s is %d\n", name, child_pid);
        return 0;
    }
    else {
        printf("My child is %d\n", child_pid);
        return 0;
    }
 
    return 0;
}


Comments

Popular posts from this blog

[OpenCV] What is gocv?

[OpenCV] Chapter01-05 Working with UI elements such as scrollbars in OpenCV window

[OpenCV] How to set up gocv