The C/C++ program below demonstrates how to create new child processes in a UNIX operating system....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The C/C++ program below demonstrates how to create new child processes in a UNIX operating system. Base the answers of the next three questions on this code. 1 #include <stdio.h> 2 #include <stdlib.h> #include <unistd.h> 4 #include <sys/types.h> #include <sys/wait.h> 3 56 7 int main() { 8 9 10 11 12 ▼ 13 14 V 15 16 17 18 19 20 Z2224127828 23 25 A 26 29 30 ▲ } 21 pid_t child_pidl, child_pid2; child_pid1= fork(); if (child_pidl == -1) { exit(EXIT_FAILURE); else if (child_pidl == 0) { child_pid2 = fork(); } if (child_pid2 == -1) exit (EXIT_FAILURE); else if (child_pid2 == 0) printf("World\n"); printf("Hello\n"); exit (EXIT_SUCCESS); printf("Welcome\n"); return 0; Question 6 How many times does the program print "Hello"? Question 7 5 pts 5 pts What is the maximum number of processes running? What statement about signals is correct? A signal generated by the occurrence of a particular event is delivered to and handled by the kernel. Threads can be cancelled immediately with asynchronous cancellation if thread has cancellation enabled. The default handler can never be overridden by a user-defined signal handler. kill(pid t pid, int signal) is a UNIX function that tells the kernel how to handle a signal generated by a specific process. The C/C++ program below demonstrates how to create new child processes in a UNIX operating system. Base the answers of the next three questions on this code. 1 #include <stdio.h> 2 #include <stdlib.h> #include <unistd.h> 4 #include <sys/types.h> #include <sys/wait.h> 3 56 7 int main() { 8 9 10 11 12 ▼ 13 14 V 15 16 17 18 19 20 Z2224127828 23 25 A 26 29 30 ▲ } 21 pid_t child_pidl, child_pid2; child_pid1= fork(); if (child_pidl == -1) { exit(EXIT_FAILURE); else if (child_pidl == 0) { child_pid2 = fork(); } if (child_pid2 == -1) exit (EXIT_FAILURE); else if (child_pid2 == 0) printf("World\n"); printf("Hello\n"); exit (EXIT_SUCCESS); printf("Welcome\n"); return 0; Question 6 How many times does the program print "Hello"? Question 7 5 pts 5 pts What is the maximum number of processes running? What statement about signals is correct? A signal generated by the occurrence of a particular event is delivered to and handled by the kernel. Threads can be cancelled immediately with asynchronous cancellation if thread has cancellation enabled. The default handler can never be overridden by a user-defined signal handler. kill(pid t pid, int signal) is a UNIX function that tells the kernel how to handle a signal generated by a specific process.
Expert Answer:
Answer rating: 100% (QA)
Lets analyze the provided CC code to answer the questions include include include include include int main pidt childpid1 childpid2 childpid1 fork if ... 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
-
A researcher wanted to find out if there was difference between older movie goers and younger movie goers with respect to their estimates of a successful actors income. The researcher first...
-
Carol Harris, Ph.D, CPA, is a single taxpayer and she lives at 674 Yankee Street, Durham, NC 27409. Her Social Security number is 793-52-4335. Carol is an Associate Professor of Accounting at a local...
-
Show that the ratio of the angular speeds of a pair of coupled gear wheels is in the inverse ratio of their respective radii.
-
Due to a computer crash, some accounting data were corrupted at Ace Industries. For the Furniture account, only some of the data were still accessible. The balance in the Accumulated...
-
Implement the clone and equals method in the Heap class.
-
The independence of an internal auditing department will most likely be assured if it reports to the: a. President. b. Controller. c. Treasurer. d. Board of directors. Choose the correct answer.
-
The Cleveland Historical Society issues $40 million of 6 percent, 15-year bonds at a price of $36,321,000 to nance the construction of a new museum. The price reects an annual yield of 7.0 percent....
-
Consideration is being given to the best option for vaccination against Hepatitis B for diabetic patients. The current standard intervention is three-dose vaccination with Engerix-B. An alternative...
-
A pulpwood loader as shown in Figure P5-63 is to be designed to lift 2.5 kip. Select a steel and determine a suitable tubular cross section for the main upright member BF that has attachments for the...
-
From the standard potentials shown in the following diagram, calculate the potentials E and E. BrO3 0.54 V Ei Bro 0.45 V 25* - 1.07 V Br- 0.76 V Br
-
CTs are used to measure the current flowing in a power system. They step down high currents to a level that can be safely measured by instruments. The reduced current is then proportional to the...
-
The Earth has a mass of 6* 1024 kg and orbit the Sun in 3.15 107 seconds at a constant radius of 1.5 101 m. Find the following: 1) What is the Earth's centripetal acceleration around the Sun? 2) What...
-
10. Find the temperature u(x, t) in the infinite plate of width 2L shown in Figure 12.R.4 if the initial temperature is uo throughout. [Hint: u(x, 0): = Uo, -L
-
4) (2 Points] Consider the following closed queueing network in which job sizes are Exponentially distributed. The service rate for each server is p =3 and # = 1, respectively. The value of p denotes...
-
You toss a tennis ball straight upward. At the moment it leaves your hand it is at a height of 1.5 m above the ground, and it is moving at a speed of 7.6 m/s. (a) How much time does it take for the...
-
A model for a certain population P(t) is given by the initial value problem P(10-5-10-14 P), P(0) = 20000000, dP dt = where t is measured in months. (a) What is the limiting value of the population?...
-
A copper rod of length L =18.0 in is to be twisted by torques T (see figure) until the angle of rotation between the ends of the rod is 3.08. (a) If the allowable shear strain in the copper is 0.0006...
-
Jason and Mary are married taxpayers in 2012. They are both under age 65 and in good health. For this tax year, they have a total of $41,000 in wages and $500 in interest income. Jason and Mary's...
-
Professor Patricia (Patty) Pate is retired from the PalmSprings Culinary Arts Academy (PSCAA). She is a single taxpayer and is 68 years old. Patty lives at 98 Colander Street, Henderson, NV 89052....
-
Mike purchases a heavy-duty truck (5-year class recovery property) for his delivery service on April 30, 2012. The truck is not considered a passenger automobile for purposes of the listed property...
-
How are fixed boundary conditions incorporated in the finite element equations?
-
True or False. The system mass matrix is always singular unless the boundary conditions are incorporated.
-
A multiple-leaf spring used in automobiles is shown in Fig. 12.17. It consists of five leaves, each of thickness \(t=0.65 \mathrm{~cm}\) and width \(w=3.8 \mathrm{~cm}\). For the multiple-leaf spring...
Study smarter with the SolutionInn App