(a) Extend the code in Figure 14.5, 14.6, or 14.7 to try to kill processes more gently....
Question:
(a) Extend the code in Figure 14.5, 14.6, or 14.7 to try to kill processes more gently. You’ll want to read the man page for the standard kill command. Use a TERM signal first. If that doesn’t work, ask the user if you should resort to KILL.
(b) Extend your solution to part (a) so that the script accepts an optional argument specifying the signal to be used. Alternatives to TERM and KILL include HUP, INT, QUIT, and ABRT.
Figure 14.5:
Figure 14.6:
Figure 14.7:
Transcribed Image Text:
O || die "usage: $0 pattern\n"; open (PS, "ps -w -w -x -o'pid,command' I"); $#ARGV == # 'process status' command
O || die "usage: $0 pattern\n"; open (PS, "ps -w -w -x -o'pid,command' I"); $#ARGV == # 'process status' command ; # discard header line while () { @words = split; # parse line into space-separated words if (/$ARGV [O1/i && $words [0] ne $$) { chomp; print; # delete trailing newline do { print "? "; $answer = ; } until $answer if ($answer kill 9, $words [0]; # signal 9 in Unix is always fatal sleep 1; die "unsuccessful; sorry\n" if kill 0, $words [0]; /* [yn]/i; /"y/i) { # wait for 'kill' to take effect # kill 0 tests for process existence
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 70% (10 reviews)
answer a ARGV 0 die usage 0 pattern open PS ps wwx opid command 1 process status command discard header line while words split parse line into spacese...View the full answer
Answered By
Churchil Mino
I have been a tutor for 2 years and have experience working with students of all ages and abilities. I am comfortable working with students one-on-one or in small groups, and am able to adapt my teaching style to meet the needs of each individual. I am patient and supportive, and my goal is to help my students succeed.
I have a strong background in math and science, and have tutored students in these subjects at all levels, from elementary school to college. I have also helped students prepare for standardized tests such as the SAT and ACT. In addition to academic tutoring, I have also worked as a swim coach and a camp counselor, and have experience working with children with special needs.
0.00
0 Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
The code in Figure 8-24 should display the pattern of ampersands shown in the figure, but it is not working correctly. Debug the code. for (int row = 1; row < 4; row + 1) { for (int col = 1; col
-
Modify the code in Figure 5.32 to measure the following system characteristics. Plot the experimental results with elapsed time on the y-axis and the memory stride on the x-axis. Use logarithmic...
-
Consider a variation on the code in Figure 15.5, in which the string concatenation inside the while loop is reversed: str = foobar; i = str.search(/[aeiou]/); while (i != -1) {str = str.substring(0,...
-
What has been the trend in sales over the years presented? July 29, July 30, 2023 2022 (Unaudited) (Unaudited) Net sales $ 5,164,072 100.0% $ 4,643,014 100.0% Cost of sales 3,115,603 60.3% 2,773,824...
-
In a dairy plant, milk at 4C is pasteurized continuously at 72C at a rate of 12 L/s for 24 h/day and 365 days/yr. The milk is heated to the pasteurizing temperature by hot water heated in a natural...
-
In problem use the RK4 method with h = 0.1 to obtain a four-decimal approximation of the indicated value. y' = xy 2 - y/x, y(1) = 1; y(1.5) x
-
What are the sources of air infiltration in condenser ?
-
At Cambridge Company, prepayments are debited to expense when paid and unearned revenues are credited to revenue when cash is received. During January of the current year, the following transactions...
-
Explain the significance of multi-scale modeling in process simulation. How does the integration of different scales, from molecular to plant-level simulations, provide a comprehensive view of...
-
The Hughes Tools Company started business on October 1, 2015. Its fiscal year runs through to September 30 the following year. The following transactions occurred in the fiscal year that started on...
-
Write a Perl, Python, or Ruby script that creates a simple concordance: a sorted list of significant words appearing in an input document, with a sublist for each that indicates the lines on which...
-
In Example 14.16 we used "$@" to refer to the parameters passed to ll. What would happen if we removed the quote marks? (Try this for files whose names contain spaces!) Read the man page for bash and...
-
A coal-fired power plant had been operating using a standard Rankine cycle to produce power. The operating conditions are as given in Illustration 5.2-1. However, the boiler is aging and will need to...
-
What is the major difference between a tax-backed debt and a revenue bond?
-
Who are the potential intermediaries in a quotedriven market?
-
Explain why the effective duration is a more appropriate measure of a complex financial instrument's price sensitivity to interest rate charges than is modified duration.
-
Yahoo.com reported that the yield for corporate bonds with 10 years to maturity on October 19, 2007, was \(5.39 \%\) for AAA rated bonds and \(5.66 \%\) for AA rated bonds. At the time, the 10 -year...
-
Comment on this statement by an official of the Federal Reserve: [the Fed] can control nonborrowed reserves through open market operations [but] it cannot control total reserves, because the level of...
-
A stationary particle of charge q = 2.6 10-8 C is placed in a laser beam (an electromagnetic wave) whose intensity is 2.5 103 W/m2. Determine the magnitudes of the (a) Electric and (b) Magnetic...
-
6. (Potential Energy and Conservation of Energy) What should be the spring constant k of a spring designed to bring a 1200-kg car to rest from a speed of 95 km/h so that the occupants undergo a...
-
Assume we want to connect two isolated hosts together to let each host communicate with the other. Do we need a link-layer switch between the two? Explain.
-
Can you explain why we did not mention multiplexing/demultiplexing services for the application layer?
-
The presentation of data is becoming more and more important in todays Internet. Some people argue that the TCP/IP protocol suite needs to add a new layer to take care of the presentation of data. If...
-
A pitcher throws a 0.60 kg ball of clay at a 4.0 kg block of wood. The clay sticks to the wood on impact, and their joint velocity afterward is 2.5 m/s. What was the original speed of the clay (in...
-
Give a summary of concepts and the applications for the following quistion: When a 200.0-g mass is attached to a spring, it stretches the spring by 7.50 cm. With that mass-spring system in...
-
A helium-filled balloon, whose envelope has a mass of 0.29 kg, is tied to a 3.8-m long, 0.054-kg string. The balloon is spherical with a radius of 0.40 m. When released, it lifts a length h of the...
Study smarter with the SolutionInn App