Apue Chapter 8 Exercise Answer

Source: Internet
Author: User

Q8.1 in Figure 8-3, if the exit call is used instead of the _exit call, then the standard output may be turned off and the PRINTFF returned-1. Modify the program to verify that this result is generated on the system you are using. If that's not the case, how do you handle it to get a similar result?

Q8.2 recalls the typical storage space layout in Figure 7-6, because the stack frame corresponding to each function call is usually stored in the stack, and because the child process runs in the address space of the parent process after calling Vfork, if it is not in the main function but in the other function, the vfork is called. What happens after the child process returns from the function? Please write a test program to verify this, and the drawing explains what happened?


Q8.3 rewrite the program in Figure 8-6, change the wait to Waitid, do not call Pr_exit, and from the siginfo structure to the top of the equivalent information.

Q8.4 when you use $./a.out to perform the program in Figure 8-13 once, the output is correct, but the output is incorrect if the program executes multiple times in the following manner.


$./a.out; a.out;/a.out

Output from parent

Ooutput from parent

Ouotuptut from

Put from parent

Output from child

Utput from

What is the reason? How can I make this kind of error more? Does this issue occur if the child process is first output?


Q8.5 in the program shown in Figure 8-20, call execl, develop pathname as the interpreter file, if you change it to call EXECLP, specify TESTINTERP's filename, and if directory/home/sar/bin is a path prefix, What is the printout of argv[2] When you run the program?

Q8.6 Write a program to create a zombie process, and then call system to execute the PS (1) command to verify that the process is a zombie process.

Q8.7 in section 8.10 mentions that posix.1 requires that the Open Directory stream be closed at exec, and this is verified in the following way: Call Opendir with the directory, view the DIR structure implemented on your system, and then print execution is the off flag. Then open the read to the same directory and print execution is the off flag.


Apue Chapter 8 Exercise Answer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.