2

I have the habit of using ctrl + c as a quick way to clear the input field in the terminal. I'm working on a set of Red Hat servers where this suddenly stopped working. I tried canceling a grep command using it (which worked before), all I get is ^C printed as a separate line, and the grep keeps working. There are cases where ctrl + c works, for instance stopping the top command.

On my Ubuntu machine hitting ctrl + c adds ^C to the line, and then gives me a new and fresh line where I can type. On the RHEL servers, it does nothing.

I'm not sure where to start looking for an issue here, any pointers?

Output from stty -a

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

Update: Output from trap:

~$ trap
trap -- '' SIGINT
trap -- '' SIGQUIT
trap -- '' SIGTSTP
trap -- '' SIGTTIN
trap -- '' SIGTTOU
Tobb
  • 161
  • 1
    Is just Ctrl+C that does not work? Can you do a Ctrl+U to clear the line? – Daniele Santi Jan 29 '19 at 15:29
  • 1
    Ctrl + U clears what is written, without giving a new input line. So I guess that is as expected. – Tobb Jan 29 '19 at 15:30
  • 1
    Yes, Ctrl-U just clears the line to the beginning. So it's just Ctrl-C which does not work. Try a stty -a | grep intr, it should be intr = ^C, it might got changed by a recent update. – Daniele Santi Jan 29 '19 at 15:45
  • 1
    What is the output of stty -a ? – Mark Plotnick Jan 29 '19 at 15:47
  • 1
    Updated question with output from stty -a. – Tobb Jan 29 '19 at 16:10
  • 1
    I might add that the servers should not have been updated from what I know. We have a puppet config handling a subset of the servers, and it works on non-puppet servers, so I'm suspecting something might have gone wrong from that source. – Tobb Jan 29 '19 at 16:12
  • 1
    try trap - INT to reset the SIGINT handler to default if it was set to ignore. –  Jan 29 '19 at 17:14
  • stty looks normal. I'd run trap to see if the shell has been set to ignore SIGINT, as @UncleBilly said. – Mark Plotnick Jan 29 '19 at 17:27
  • The output of stty will be misleading here. Your question needs to state what shell you are using. – JdeBP Jan 29 '19 at 20:50
  • I'm using bash, added the tag. – Tobb Jan 30 '19 at 10:26
  • @UncleBilly That did the trick :D Do you know if there is a way to configure this on multiple servers, using puppet? – Tobb Jan 30 '19 at 10:27
  • in Emacs Ctrl+U deletes to the left, Ctrl+K clears to the right and I often use them to clear the whole line. Some other useful shortcuts: Alt+F move forward one word, Alt+B move back one word, Ctrl+W delete word, Alt+D delete next word – phuclv Jan 30 '19 at 14:11
  • The default for bash is to not catch or ignore SIGINT. You may have some init file that is doing trap "" SIGINT. See Which startup file is being used by my shell? to see if one of its init files has that trap line. – Mark Plotnick Jan 30 '19 at 17:27
  • Ok, so one of your shell's startup files seems to set traps to ignore specific signals for some reason. It may be your personal ~/.bashrc or ~/.bash_profile (or similar) file, or one of the /etc/*profile* files. See if you can find it and see if it's accompanied by some comment. – Kusalananda Jul 29 '19 at 13:27
  • Would that be a command starting with trap? – Tobb Jul 29 '19 at 13:48
  • @Tobb Yes, it would be a command involving the trap command. – Kusalananda Jul 29 '19 at 15:40

1 Answers1

0

In my case, the following did the trick:

trap - INT

Tobb
  • 161
  • So, what installed an INT trap in you shell? – Kusalananda Jul 29 '19 at 11:16
  • I have no idea :( – Tobb Jul 29 '19 at 13:08
  • If it was a trap, what was it? What does the trap command by itself output (before you removed the trap with the command in your answer)? (I'm only trying to pry some extra information out from you to make the answer more useful for others with similar issues. At the moment, it's "I had this issue, and this solved it", but it lacks a because part that would not only show why the answer solved the issue but why the issue was there in the first place). – Kusalananda Jul 29 '19 at 13:20
  • Started a new session against the same server, and the problem was back. Might be because the session where I fixed it is still active. Anyways, added output from trap to my question – Tobb Jul 29 '19 at 13:25
  • Problem seems to reappear when I open a new session. Difference in trap output before and after running the command is that this goes away: trap -- '' SIGINT. Don't know why it appears in the first place though. – Tobb Jul 29 '19 at 13:27