My Profile
Active Members
TodayLast 7 Days
more...
Awards & Gifts
Online Exams
Fresher Jobs
Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian
cities including Bangalore, Chennai, Hyderabad, Pune or Kochi
Resources
Find educational articles, blogs, discussion threads and other resources.
Colleges
Find details about any college in India or search for courses.
|
Resources » Articles/Knowledge Sharing » General »
Usage of fork, sleep, exec, wait system calls program in c
|
#include int execl(char *path , char *arg0,...); main() { int a; system("clear"); a = fork(); printf("\n \n Execution after fork()"); if(a==0) { printf("\nIm child process with PID %d" , getpid()); printf("\nHere ,value of a =%d",a); printf("\nGoing to execute sample calling 'sh'"); system("sh sample"); printf("\n The image of process is retained \n\n\n"); wait(); } else { sleep(4); printf("\n Im parent process with PID %d",getppid()); printf("\n Here , value of a = %d(childs PID)",a); printf("\nGoing to execute sample using exec ie by replacing the image of process with the sample programs image \n"); execl("/bin/sh","sh","sample",(char *)0); printf("\n The Statement will not be executed image replaced"); wait(); } }
|
Responses
|
No responses found. Be the first to respond and make money from revenue sharing program.
|
|
Advertise Here
|