(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: 66% (9 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...
-
The San Francisco Giants want to boost revenues from ticket sales next season. You are hired as an economic consultant and asked to advise the Giants whether to raise or lower ticket prices next...
-
Fun-Tastic Shows, Inc., is a company that hosts carnivals and similar events. Susan Swartwood, Crystal Groth, and a minor (named in the case as M.G.S.) attended Fun-Tastics Rhododendron Festival in...
-
Windhoek Mines, Ltd., of Namibia, is contemplating the purchase of equipment to exploit a mineral deposit on land to which the company has mineral rights. An engineering and cost analysis has been...
-
Develop an algorithm, in the form of a Raptor flowchart, to compute and display the amount of federal income tax to be paid when provided with the income as input. The Canadian Federal income tax...
-
Consider Nike and Adidas, download their balance sheets and income statements for a period of 3 years. You are required to critically evaluate the financial statements individually across the 3-year...
-
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...
-
Assume that interest rate parity exists. Also assume that you have payables in Argentine pesos. You have noticed that historically, the forward rate of the Argentine peso quoted by the banks exhibits...
-
1. How would you define leadership? 2. Not all effective leaders seems to be reflective by nature. How do you reconcile that with the concept of the spiral of experience and its role in leadership...
-
A scale measures the weight of a light object to be 11.000 lbs 0.034 lbs. What is the uncertainty if this same scale is used to measure an object that weighs 78.000 lbs? Assume that the percent...
-
Below are descriptions of 5 different notes. Each represents a different type of note we discussed in class. Use this information to answer the following questions: Note 1: ABC will require XYZ to...
-
1. Define a Clear scope statement and anticipated outcomes for your project (i.e. description of what will be different in the PMPG program after your project has been implemented) 2. A clear...
-
Assume that you are an organizational consultant and have been asked by a new CEO to evaluate the strengths and weaknesses of the organization.
-
Explain the functions of a lymph node.
-
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...
-
Your web application's database is MySQL.How you can establish the database connection and if database connection is failed, you able to detect the errors that cause the database connection failed....
-
I am facing a Database connection error (2). Could not connect to MySQL. error. Source codes are: Database Error Error establishing a database connection. Database connection error (2). Could not...
-
How can we add database connection script to store form input values into MySQL Database Table such as LogIn tables.
Study smarter with the SolutionInn App