Monday, 10 March 2014

Program to implement System Call


/*Program to implement System Call*/



#include<stdio.h>
main()
{
int pid;
printf("DATE:(To be printed by child process)\n");
pid=fork();
switch(pid)
{
case -1:printf("FORK FAILED");
exit(1);
case 0:printf("\n CHIELD PROCESS ID IS: %i",getpid());
execl("/bin/date","date",(char*)0);
break;
default:break;
}
wait(10);
printf("\nPARET PROCESS ID: %i \n",getpid());
}

OUTPUT :


guest-vLoOth@computer-OptiPlex-745:~$ cc sc.c

guest-vLoOth@computer-OptiPlex-745:~$ ./a.out

DATE:(To be printed by child process)
Mon Mar 10 14:23:49 IST 2014
PARET PROCESS ID: 2537

No comments:

Post a Comment