Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Get the current function used to handle control+z

by diotalevi (Canon)
on Dec 14, 2008 at 05:51 UTC ( #730255=note: print w/ replies, xml ) Need Help??


in reply to Get the current function used to handle control+z

The key press Control-z is typically mapped by your termcap or terminfo database to the capability susp. Your terminal interprets that and sends a SIGSTOP signal to your foreground process. SIGSTOP is 19 on the CentOS box I looked at and 17 on the Mac OS X machine I also looked at. The kill program on your *NIX takes a signal name. kill() in Perl doesn't though the Config module stores your local system's mapping as well.

system "kill -STOP $$"; # stop self

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊


Comment on Re: Get the current function used to handle control+z
Select or Download Code
Re^2: Get the current function used to handle control+z
by friedo (Prior) on Dec 14, 2008 at 07:46 UTC

    It's a little clunky, but you can do the kill from within perl by counting SIGSTOP's position in $Config{sig_name} (which, unfortunately, is a space-separated list rather than an array.)

    perl -MConfig -le 'for( split /\s/, $Config{sig_name} ) { last if /^STOP$/; $n++ } kill $n, $$'
    This just counts signal names until it gets to STOP, and $n will contain the right number.

      There's no need to search signal number in $Config
      kill STOP => $$;
      will work just fine.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://730255]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2014-10-24 08:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (131 votes), past polls