Answers for "pid of a process in c"

C
0

pid of a process in c

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

int main()
{
    int pid = 0;
    printf("before the fork n");
    pid = fork(); //create the child process
    printf("after the fork n");
    if (pid == 0)
    {
        printf("I'm the child process, my pid is &dn", getpid());
        exit(1);
    }
    else
    {
        printf("I'm the parent process, my pid is &dn", getpid());
        exit(0);
    }
}
Posted by: Guest on November-14-2021
-1

c program to print pid of a process

Process ID: 1298
Parent Process ID: 879
Posted by: Guest on March-18-2021

Code answers related to "pid of a process in c"

Code answers related to "C"

Browse Popular Code Answers by Language