What does the following C program print [4 points] and why [7 points]? Note that emphasis...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
What does the following C program print [4 points] and why [7 points]? Note that emphasis of this question is on your understanding of the signal functionality. State your assumptions where necessary. pid_t pid; void h1(int sig) { } printf("eagle"); kill(pid, SIGUSR2); void h2(int sig) { } printf("sparrow"); exit(0); main() { signal(SIGUSR2, h1); if ((pid fork()) == 0) { signal(SIGUSR2, h2); } kill(getppid(), SIGUSR2); while(1) {}; else { pid_t p; int status; if ((p = wait(&status)) > 0) { printf("pigeon"); } } } What does the following C program print [4 points] and why [7 points]? Note that emphasis of this question is on your understanding of the signal functionality. State your assumptions where necessary. pid_t pid; void h1(int sig) { } printf("eagle"); kill(pid, SIGUSR2); void h2(int sig) { } printf("sparrow"); exit(0); main() { signal(SIGUSR2, h1); if ((pid fork()) == 0) { signal(SIGUSR2, h2); } kill(getppid(), SIGUSR2); while(1) {}; else { pid_t p; int status; if ((p = wait(&status)) > 0) { printf("pigeon"); } } }
Expert Answer:
Answer rating: 100% (QA)
Signal Handlers h1int sig is a signal handler for SIGUSR2 signal It prints eagle and sends SIGUSR2 t... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Which one of the follow is correct when considering business letters? 1. The Opening, Body and Closing sections of a routine, persuasive or negative business letter, with minor alterations, could be...
-
Python and most Python libraries are free to download or use, though many users use Python through a paid service. Paid services help IT organizations manage the risks associated with the use of...
-
Q1. You have identified a market opportunity for home media players that would cater for older members of the population. Many older people have difficulty in understanding the operating principles...
-
A car costs 12,000. It will be kept for three years, and then sold for 3,000. Calculate the depreciation for each year using (a) the reducing balance method, using a depreciation rate of 35 per cent,...
-
Ayaunna starts 2.0 m from a motion sensor. She walks away from the sensor at a rate of 1.0 m/s for 3.0 s and then walks toward the sensor at a rate of 0.5 m/s for 4.0 s. a. Create a table of values...
-
You work in a hospital and are preparing a saline solution for a patient. This solution must have a concentration of \(0.15 \mathrm{~mol}\) of \(\mathrm{NaCl}\) (mass of one mole, \(58.44...
-
2. YOU BE THE JUDGE WRITING PROBLEM An off-duty, out-of-uniform police officer and his son purchased some food from a 7-Eleven store and were still in the parking lot when a carload of teenagers...
-
On June 10, Naveen Company purchased $8,000 of merchandise from Jarrah Company, FOB shipping point, terms 2/10, n/30. Naveen pays the freight costs of $400 on June 11. Damaged goods totaling $300 are...
-
What is the rational for wealth maximization as a goal for a firm? What are the key financial statements and why they are important? What is the purpose of ratio analysis? please answer every...
-
Since East Coast Yachts is producing at full capacity, Larissahas decided to have Dan examine the feasibility of a newmanufacturing plant. This expansion would represent a major capitaloutlay for t 2...
-
Hospitality in the Big City1. How does this case illustrate the importance of 2. How important is it to defuse unpleasantness even 3.Describe any similar experiences you may havehad where people...
-
Over the year, the Mars company has changed both the colors and the proportion of colors for M&M candies. The original colors were red, yellow, violet, green and brown. In 1995 blue was introduced....
-
Questions below based on figure above: Consider the Arithmetic Logic Unit (ALU) block diagram shown in Fig. 1(a). Each block is numbered in brackets, for example (1), (2)... (10). The D-Flip-Flops...
-
Inventory Beginning Balance Ending Balance $27,000 Accounts Receivables 21,000 Accounts Payables 10,000 $28,000 22,000 14,000 Consider the above balances and if Credit Sales were $175,000 and the...
-
44x If a basketball player shoots a foul shot, releasing the ball at a 45-degree angle from a position 6 feet above the floor, then the path of the ball can be modeled by the quadratic function, h(x)...
-
You are serving a tennis ball by hitting it horizontally at a height of hball = 2.0 meters above the ground with an initial speed vo. The ball must travel a distance D = 10.0 m and must clear the net...
-
List four items of financial information you consider to be important to a manager of a business that has been operating for a year.
-
Rebecca and Walter Bunge have been married for 5 years. They live at 883 Scrub Brush Street, Apt. 52B, Las Vegas, NV 89125. Rebecca is a homemaker and Walt is a high school teacher. Rebecca's Social...
-
Ann hires a nanny to watch her two children while she works at a local hospital. She pays the 19-year-old nanny $125 per week for 48 weeks during the current year. a. What is the employer's portion...
-
Bea Jones (age 32) moved from Texas to Florida in December 2011. She lives at 654 Ocean Way, Gulfport, FL 33707. Bea's Social Security number is 466-78-7359 and she is single. Her earnings and income...
-
A store declares a deep discount of \(40 \%\) for an item, which they say will save \(\$ 30\). What was the original price of the item?
-
Simplify the irrational number \(\sqrt{1,815}\).
-
Simplify the irrational number \(\sqrt{550}\) and express in lowest terms. Identify the rational and irrational parts.
Study smarter with the SolutionInn App