Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

"For example, on *nix/POSIX the only mechanism I know of, for terminating a running process, is to send it a signal. But signals are maskable, trappable, and ignorable. Are any of them guaranteed to terminate the process? Do you know the answer? I don't. Do you think he does?"

I certainly can't answer for all OSes, nor even all Unix-like OSes, but on Linux, SIGKILL (signal 9) cannot be trapped. SIGKILL is essentially the untrappable version of SIGINT (which is what Ctrl+C tends to send in the terminal).

Also, SIGSTOP cannot be caught, but SIGSTOP doesn't kill a process, it pauses it. SIGSTOP is the untrappable version of SIGTSTP (which is what Ctrl+Z tends to send in the terminal).

Of course, just because a process cannot trap and handle the signal, doesn't mean that the signal is 100% instant and reliable. Signals can fail to work, or take some time to work for other reasons (e.g. bugs, busy CPU, etc).

Aside: If a process is chewing up your CPU and you need to stop it for a while, kill -s STOP <process_number> is a pretty handy facility. When you're happy for it to start chewing again kill -s CONT <process_number> will restart it. The process is unlikely to even notice you paused it.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

In reply to Re^3: ***Warning! The above post is wrong in almost every possible way*** by tobyink
in thread Kill a process in perl windows and proceed only if it killed the process by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-03-29 01:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found