Operating System - HP-UX
1833797 Members
4714 Online
110063 Solutions
New Discussion

Regarding Control+D & Control+C

 
SOLVED
Go to solution
Praveen Motupalle
Occasional Contributor

Regarding Control+D & Control+C

I need small help to understand how it will works Control-D and Control-C for terminating remote session or any application.

When i press ControlD or ControC which process it will stopor which are the steps will run backend.

Thanks & Regards - Praveen
5 REPLIES 5
Torsten.
Acclaimed Contributor
Solution

Re: Regarding Control+D & Control+C

Do you know about signals?

CTRL C = SIGINT

start to read here:

http://en.wikipedia.org/wiki/Signal_%28computing%29

or here

http://docs.hp.com/en/B2355-60105/kill.1.html

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Dennis Handly
Acclaimed Contributor

Re: Regarding Control+D & Control+C

Control-D sets EOF. This is the end of your application's data.
You can get your shell to ignore: set -o ignoreeof
(You will have to use exit to logout.)
Laurent Menase
Honored Contributor

Re: Regarding Control+D & Control+C

In fact it is processed by your tty.

When you press ^C, and if your tty is configured with ^C set for intr, then it will send a SIGINTR to the forground process.

The mapping of such controls are set via stty

stty -a
# stty -a
speed 9600 baud; line = 0;
rows = 24; columns = 80
min = 4; time = 0;
intr = ^C; quit = ^\; erase = ^H; kill = ^U
eof = ^D; eol = ^@; eol2 ; swtch
stop = ^S; start = ^Q; susp ; dsusp
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

If I want that ^X as kill I just type
stty kill ^X

Then if ^X is pressed it will send a sigkill to the foreground process.
A. Clay Stephenson
Acclaimed Contributor

Re: Regarding Control+D & Control+C

The most important aspect of this question is that the answer can only be "it depends". How a given process responds to a given signal is entirely up to the process. In fact, (assuming that Cntl-C generates a SIGINT) a Ctrl-C might cause the process to do one behavior at one point and another behavior at another point because the signal handler can be changed while the process is running. The signal handler may be null, in which case the signal is ignored.
If it ain't broke, I can fix that.
Dennis Handly
Acclaimed Contributor

Re: Regarding Control+D & Control+C

>Clay: The signal handler may be null, in which case the signal is ignored.

Actually you have to use SIG_IGN. SIG_DFL just randomly happens to be 0. :-)