Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

pid of a process in c

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

int main()
{
    int pid = 0;
    printf("before the fork 
");
    pid = fork(); //create the child process
    printf("after the fork 
");
    if (pid == 0)
    {
        printf("I'm the child process, my pid is &d
", getpid());
        exit(1);
    }
    else
    {
        printf("I'm the parent process, my pid is &d
", getpid());
        exit(0);
    }
}
 
PREVIOUS NEXT
Tagged: #pid #process
ADD COMMENT
Topic
Name
3+3 =