This program shows how to create process and display Process ID (pid) of Both Parent and Child processes. The process is created using the fork system call in UNIX (Linux) operating systems.
#include<stdio.h>
#include<dirent.h>
main(int argc,char **argv)
{
int pid,i;
for(i=0;i<atoi(argv[1]);i++)
{
pid=fork();
if(pid==0)
{
printf("child process id %d Parent process
id %d\n",getpid(),getppid());
}}}
Information about resetting and configuring Mobile phones (Java, Android, Symbian etc), educational articles especially for programming in C, C++ and Java and more about Computers and operating systems
How to Create process and display Process ID (pid) of Both Parent and Child
Labels:
$ccpp
,
c program
,
code
,
compiled
,
create
,
display
,
fork
,
getpid
,
lab
,
Linux
,
operating Systems
,
OS
,
Oslab
,
process
,
process id
,
programming
,
source code
,
system call
,
UNIX
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment