1820309 Members
2617 Online
109623 Solutions
New Discussion юеВ

Ctrl+C problem

 
SOLVED
Go to solution
haeman
Frequent Advisor

Ctrl+C problem

In my system , root user can use the ctrl+C ( break the running process ) , but general user can't use it , I tried to export the stty as below , both user ( root and general) are the same , can advise what is wrong ? thx


#stty -a
speed 9600 baud; rows 25; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^H; kill = ^U; eof = ^D; eol = ;
eol2 = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^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 -xcase -tostop -echoprt
echoctl echoke
8 REPLIES 8
Robert-Jan Goossens
Honored Contributor

Re: Ctrl+C problem

Hi Haeman,

what kind of shell does your general user use?

Robert-Jan
haeman
Frequent Advisor

Re: Ctrl+C problem

bash

thx
Dennis Handly
Acclaimed Contributor

Re: Ctrl+C problem

>bash

Why don't you use a real shell to see if cntl-C works at all? (ksh or sh)
Steven Schweda
Honored Contributor
Solution

Re: Ctrl+C problem

> [...] my system [...]

This does not describe the system very well.

> bash

This does not describe the shell very well.

> [...] general user can't use it

This does not describe the problem very well.

Ctrl/C seems to work as expected on my local
system (PA-RISC, 11.11, bash 3.2 (I
believe)), and on a TestDrive system like
td176.testdrive.hp.com (IA64, 11.23, "GNU
bash, version 3.00.14(1)-release
(ia64-hp-hpux11.23)").

td176> stty -a
speed 9600 baud; line = 0;
rows = 24; columns = 80
min = 4; time = 0;
intr = ^C; quit = ^\; erase = DEL; kill = ^U
eof = ^D; eol = ^@; eol2 ; swtch
stop = ^S; start = ^Q; susp = ^Z; dsusp = ^Y
werase ; lnext
parenb -parodd cs7 -cstopb hupcl -cread -clocal -loblk -crts
-ignbrk brkint ignpar -parmrk -inpck istrip -inlcr -igncr icrnl -iuclc
ixon -ixany -ixoff -imaxbel -rtsxoff -ctsxon -ienqak
isig icanon -iexten -xcase echo echoe echok -echonl -noflsh
-echoctl -echoprt -echoke -flusho -pendin
opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel -tostop tab3

It might also help to know where you're
sitting (HP-UX workstation, Windows box with
some mal-configured terminal emulator, a
real VT220, ...), how you're connected, and
what you're doing.
Garry Ferguson
Frequent Advisor

Re: Ctrl+C problem

I had a similar problem.
Try commenting out the "trap" commands in
/etc/profile
I never fully understood why in should help but it did !!?


haeman
Frequent Advisor

Re: Ctrl+C problem

thx reply ,

I tried to remark the line " trap 1 2 3" in /etc/profile , it works, can advise what is the function of this line ? if disable it , what is the impact ?

thx
Dennis Handly
Acclaimed Contributor

Re: Ctrl+C problem

>can advise what is the function of this line? if disable it, what is the impact?

When signals 1, 2 or 3 are issued, it goes to the commands in the trap command. If none, the signal is ignored.

Typically in a real shell, the trap commands in /etc/profile are ignored after the shell is set up. If you remove it, it is possible to break out of the commands that /etc/profile is executing.

You may want to just reset the traps at the end of the script:
trap - 1 2 3
Dennis Handly
Acclaimed Contributor

Re: Ctrl+C problem

>You may want to just reset the traps at the end of the script:
trap - 1 2 3

A similar statement is at the end of my /etc/profile:
# Leave defaults in user environment.
trap 1 2 3