Create a new file named wait_status.c using the below code. Compile it as wait_status and run the
Fantastic news! We've Found the answer you've been seeking!
Question:
![image text in transcribed](https://s3.amazonaws.com/si.experts.images/answers/2024/06/667ac0f79718c_823667ac0f76ebb5.jpg)
![image text in transcribed](https://s3.amazonaws.com/si.experts.images/answers/2024/06/667ac0f829c21_824667ac0f803c01.jpg)
![image text in transcribed](https://s3.amazonaws.com/si.experts.images/answers/2024/06/667ac0f889135_824667ac0f875af1.jpg)
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;
![image text in transcribed](https://s3.amazonaws.com/si.experts.images/answers/2024/06/667ac0f905190_824667ac0f8db3ed.jpg)
![image text in transcribed](https://s3.amazonaws.com/si.experts.images/answers/2024/06/667ac0f98af7a_825667ac0f96fffa.jpg)
![image text in transcribed](https://s3.amazonaws.com/si.experts.images/answers/2024/06/667ac0f9f3975_825667ac0f9deb81.jpg)
Related Book For
Business Analytics
ISBN: 9780357902219
5th Edition
Authors: Jeffrey D. Camm, James J. Cochran, Michael J. Fry, Jeffrey W. Ohlmann
Posted Date: