[Linux] What SIGNAL is associated to a CTRL+ combination ??? (SOLVED)


You can't use Ctrl-Z from a command line program, it's handled by the shell.
I still don't understand what you're actually trying to do. Are you trying to trap signals or handle ctrl combos?
 
I wanted to trap the signal just to disable it's shell function (that stops a program), so the program I launch can grab the combination and use it for other things... then after exiting the program I could just enable again the normal behaviour of the signal... without modifying anything else
 
If you type 'stty intr undef' and 'stty susp undef' then run your program, does it not do what you want? I'm also a little confused as to what you're trying to achieve if that isn't sufficient.
 
If you type 'stty intr undef' and 'stty susp undef' then run your program, does it not do what you want? I'm also a little confused as to what you're trying to achieve if that isn't sufficient.

Yeah, this works, I was a little lost because I didn't see that ^z was present 2 times in the configuration, for both swtch and susp, so seeing only the first I didn't understood how it was able to stop programs...
anyway, using this method it's a little more complicated than just disabling the signals... but I'll live with it
Thanks :)
 
Hmm, that's weird (to have two options set as ^z). If you type 'stty' without the -a does it list just one line of output, or more? Invoking 'stty sane' will undo anything on the second or more line of plain 'stty' output.

FWIW on my system, I have -brkint, -imaxbel and iutf8 defined on that second line of output. I've not been able to find where in my bootup sequence they come from yet, but they don't seem to be insensible settings so I'll leave them.
 
Hmm, that's weird (to have two options set as ^z). If you type 'stty' without the -a does it list just one line of output, or more?

Code:
$ stty
speed 38400 baud; line = 0;
-imaxbel
-echoe -echok -echoctl -echoke

$ stty -a
speed 38400 baud; rows 71; columns 271; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = ^Z; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo -echoe -echok -echonl -noflsh -tostop -echoctl -echoke -flusho

I'm working on the automation to disable all the combinations and I'm already lost... stty seems not able to accept parameters from pipes :(
I tried also with and without xargs
(found a solution)

This is what I have for now:
Code:
# Saves original settings on a file
stty -g > stty_bkp

# Sets to undef all the ctrl combinations
stty $(stty -a | sed 's/;\s*/;\n/g' | grep "\^" | sed 's/\(\w*\)\s*=\s*\(.*\)\s*;/\1 undef /g' | tr -d '\n')

# Program to be run
$1

# Recall original settings
stty $(cat stty_bkp)

EDIT:
oh, nothing, found a workaround and corrected the script above, now I'm happy :D

Thank you all :cool:
 
Last edited:
That's really complicated. Achieve the same thing with
set +m
#program to be run
set -m
 
Yeah, it disables the Ctrl-Z sending SIGSUSP, which is untrappable, so you can actually handle it yourself. Is that not what you wanted?
 
I wanted to disable every CTRL combinations, but while some of them where "somehow" working even if not disabled (at least weren't exiting the program), the CTRL-Z was just the most troublesome...
 
Back
Top