Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Parallel Processing ProgramsRSS Feeds

Program of an orphan

Posted By: Mohammed Evans     Category: C Programming     Views: 2220

Write a Program of an orphan.

Code for Program of an orphan in C Programming

#include<stdio.h>

main()
{
    int id;

    printf("Before fork()\n");
    id=fork();

    if(id==0)
    {
        printf("Child has started: %d\n ",getpid());
        printf("Parent of this child : %d\n",getppid());
        printf("child prints 1 item :\n ");
        sleep(10);
        printf("child prints 2 item :\n");
    }
    else
    {
        printf("Parent has started: %d\n",getpid());
        printf("Parent of the parent proc : %d\n",getppid());
    }

    printf("After fork()");
}
  
Share: 


Didn't find what you were looking for? Find more on Program of an orphan Or get search suggestion and latest updates.

Mohammed Evans
Mohammed Evans author of Program of an orphan is from London, United Kingdom.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!