Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a new file named wait_status.c using the below code. Compile it as wait_status and run the below code. (1) What is the output? Explain
Create a new file named wait_status.c using the below code. Compile it as wait_status and run the below code.
(1) What is the output? Explain why?
(2) Change exit(1) to exit(1000)? Compile and run it. What is the output? Explain why?
#include
#include
#include
#include
void waitexample()
{
int stat;
if (fork() == 0)
exit(1);
else
wait(&stat);
if (WIFEXITED(stat))
printf("Exit status: %d ", WEXITSTATUS(stat));
else if (WIFSIGNALED(stat))
psignal(WTERMSIG(stat), "Exit signal");
}
int main()
{
waitexample();
return 0;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started