Question: What is the output of the following two programs? //Program 1 main () {int val = 5; if(fork() > 0){wait{$val); val - WEXITSTATUS(val);} val++; printf(%d

What is the output of the following two programs?

What is the output of the following two programs? //Program 1 main

//Program 1 main () {int val = 5; if(fork() > 0){wait{$val); val - WEXITSTATUS(val);} val++; printf("%d ", val); return val;}//Program 2 main() {int val = 5; if (for3?() > 0) {wait($val); val = EXITSTATUS(val);} else exit(val); val++; printf("%d ", val); return val;} Here is a description of the return value of wait() from the corresponding UNIX manpage: RETURN VALUES When wait () returns due to a terminated child process, the process ID of the child is returned to the calling process. Otherwise, -1 is returned and error is set to indicate the error. ERRORS The wait() function will fail if: ECHILD The calling process has no existing unwaited-for child processes

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!