#include<stdio.h>
int main()
{
int forkRet;
forkRet=fork();
if(forkRet==0)
{
printf("Fork Return value=%d\n",forkRet
); printf("Process Id=%d ",getpid
()); printf("Parent Process ID=%d,getppid()); }
else
{
printf("In Parent \n");
printf("Fork Return value=%d\n",forkRet);
printf("Process Id=%d ",getpid());
printf("Parent Process ID=%d,getppid());
}
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KaW50IG1haW4oKQp7CiBpbnQgZm9ya1JldDsKIGZvcmtSZXQ9Zm9yaygpOwogaWYoZm9ya1JldD09MCkKIHsKIHByaW50ZigiSW4gQ2hpbGQgXG4iKTsKIHByaW50ZigiRm9yayBSZXR1cm4gdmFsdWU9JWRcbiIsZm9ya1JldCk7CiBwcmludGYoIlByb2Nlc3MgSWQ9JWQgIixnZXRwaWQoKSk7CiBwcmludGYoIlBhcmVudCBQcm9jZXNzIElEPSVkLGdldHBwaWQoKSk7CiB9CiBlbHNlCiB7CiBwcmludGYoIkluIFBhcmVudCBcbiIpOwogcHJpbnRmKCJGb3JrIFJldHVybiB2YWx1ZT0lZFxuIixmb3JrUmV0KTsKIHByaW50ZigiUHJvY2VzcyBJZD0lZCAiLGdldHBpZCgpKTsKIHByaW50ZigiUGFyZW50IFByb2Nlc3MgSUQ9JWQsZ2V0cHBpZCgpKTsKIH0KIHJldHVybiAwOwp9Cg==
prog.c: In function 'main':
prog.c:5:2: warning: implicit declaration of function 'fork' [-Wimplicit-function-declaration]
forkRet=fork();
^
prog.c:10:2: warning: implicit declaration of function 'getpid' [-Wimplicit-function-declaration]
printf("Process Id=%d ",getpid());
^
prog.c:11:9: warning: missing terminating " character
printf("Parent Process ID=%d,getppid());
^
prog.c:11:2: error: missing terminating " character
printf("Parent Process ID=%d,getppid());
^
prog.c:12:2: error: expected expression before '}' token
}
^
prog.c:12:2: error: expected ';' before '}' token
prog.c:18:9: warning: missing terminating " character
printf("Parent Process ID=%d,getppid());
^
prog.c:18:2: error: missing terminating " character
printf("Parent Process ID=%d,getppid());
^
prog.c:19:2: error: expected expression before '}' token
}
^
prog.c:19:2: error: expected ';' before '}' token