study 6/7 - combined questions: 0: With fork if you have int x; /* global hence zero */ main() if (fork() == 0) { x++; exit(0); } wait(); printf("%d\n", x); what does the printf print as the value of x? -------- signal questions -------------------------------------- 1. give the code for handling an alarm every ten seconds where the alarm should happen twice. After the second alarm exit. Before the second alarm return. 2. what is the proper way to catch asynchronous zombies using SIGCHLD, etc? 3. explain the following signals: SIGKILL SIGSEGV SIGINT SIGCHLD SIGALRM 4. what do these function calls do: sleep() pause() 5. give a short code example that would catch a SIGSEGV. Include code that would cause a SIGSEGV. 6. give a rough explanation of what happens when a SIGSEGV occurs. 7. why is it NOT a good idea to return from a SIGSEGV exception handler if you catch one? 8. If you call alarm in ten seconds and have no signal handler, what will happen? 9. what is meant by polling an event? can you give an example. Why is this necessariy with the SIGCHLD signal? 10. explain how one could make a nice linked list pointer fiasco by combining malloc/free with a signal. What could be done theoretically to prevent this from happening (besides not using malloc/free)? -- Jim Binkley