Logo 
Search:

C Programming Articles

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

PROGRAM FOR ORPHAN PROCESS

Posted By: Alexander Evans     Category: C Programming     Views: 7256

PROGRAM FOR ORPHAN PROCESS.

Code for PROGRAM FOR ORPHAN PROCESS 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()");
}


OUTPUT
***********
[04mca58@LINTEL 04mca58]$  cc orphan.c
[04mca58@LINTEL 04mca58]$  ./a.out
Before fork()
Parent has started: 2899
Child has started: 2900
Parent of this child : 2899
child prints 1 item :
Parent of the parent proc : 616
After fork()
[04mca58@LINTEL 04mca58]$   child prints 2 item :
After fork()
  
Share: 


Didn't find what you were looking for? Find more on PROGRAM FOR ORPHAN PROCESS Or get search suggestion and latest updates.

Alexander Evans
Alexander Evans author of PROGRAM FOR ORPHAN PROCESS is from London, United Kingdom.
 
View All Articles

 
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!