CS计算机代考程序代写 #include

#include
#include
#include
#include

int main(int argc, char* argv[]) {
int pid;
printf(“Before: process id %d\n”,getpid());

if ((pid = fork())==0){
printf(“I am the child %d\n”,getpid());
sleep(5);
printf(“Listing content of current directory…\n”);
execlp(“ls”,”ls”,”-l”, (char *)0);
}
else{
printf(“I am the parent %d\n”, getpid()); int status;

int term_pid = wait(&status);
printf(“Child %d has listed the content of current directory\n”, term_pid); exit(1);
}
}