Thursday, 4 December 2014

program to refer process id's in UNIX


#include"myHeader.h"
main()
{
int i;
printf("process:%d\n",getpid());
for(i=1;i<=3;i++)
{
fork();
printf("process id:%d\n",getpid());
}
printf("exiting ......\n");
}
OutPut:
madan@madan-Lenovo-G570:~/madan/osconcepts$ cc ex33.c
madan@madan-Lenovo-G570:~/madan/osconcepts$ ./a.out
process:5492
process id:5492
process id:5492
process id:5494
process id:5492
exiting ......
process id:5494
exiting ......
process id:5495
exiting ......
process id:5496
exiting ......
process id:5493
process id:5493
process id:5493
exiting ......
madan@madan-Lenovo-G570:~/madan/osconcepts$ process id:5497
process id:5498
process id:5497
exiting ......
exiting ......
process id:5499
exiting ......