Question 3: [2+2]
a) What, to whom and how many values a fork system call returns?
b) Assuming there is no syntax error, what is the output for the following C program for linux? All of you may need to put screenshot of your PC in which Terminal login must be your arid number.
int main()
{ pid_t fork_return;
fork_return = fork();
if (fork_return == 0) {
execlp("/bin/ls", "ls", NULL);
printf("Child process ID: %d\n", getpid());
exit(0);
}
else { wait (NULL);
printf("Parent process ID: %d\n", getpid());
}
return 0;
}
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
Question 3: [2+2] a)What, to whom and how many values a fork system call returns? b)Assuming there is no syntax error, what is the output for the following C program for linux? All of you may need to put screenshot of your PC in
Arid No is 19-arid-898Question 3: [2+2]a) What, to whom and how many values a fork system call returns? b) Assuming there is no syntax error, what is the output for the following C program for linux? All of you may need to put screenshot of your PC in which Terminal login must be your arid number.int main(){ pid_t fork_return; fork_return = fork(); if (fork_return == 0) { execlp("/bin/ls", "ls", NULL); printf("Child process ID: %d\n", getpid()); exit(0); } else { wait (NULL); printf("Parent process ID: %d\n",...
Source code to modify:
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main()
{
pid_t pid;
/*fork a child process*/
pid = fork();
if (pid<0){ /*error occured*/
fprintf(stderr,"Fork failed\n");
return 1;
}
else if (pid == 0) { /*child process */
printf("I am the child %d\n",pid);
execlp("/bin/ls","ls",NULL);
}
else { /*parent process */
/*parent will wait for the child to complete*/
printf("I am the parent %d\n",pid);
wait(NULL);
printf("Child Complete\n");
}
return 0;
}
1. Write program codes for 3.21 a and...
Edit the code (shell.c) given to do the tasks asked! will rate
for correct answer! Also, include a screen shot of the output and
terminal window of each command you used. Read carefully to do this
task please.
shell.c code given below.
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <string.h>
int main()
{
int PID;
char lineGot[256];
char *cmd;
while (1){
printf("cmd: ");
fgets(lineGot, 256, stdin); // Get a string from user (includes \n)
cmd = strtok(lineGot, "\n");...