Operating System - HP-UX
1820478 Members
3086 Online
109624 Solutions
New Discussion юеВ

<ctrl>d and 'exit' difference?

 
SOLVED
Go to solution
Myles McManus
Frequent Advisor

<ctrl>d and 'exit' difference?

When logging out of some user shells I find that when I use d I get a message saying something like "Use 'exit' to log out". Why would this be? What is the difference between using d and 'exit' when logging out?

-Myles
There's no place like $HOME.
5 REPLIES 5
Michael Steele_2
Honored Contributor

Re: <ctrl>d and 'exit' difference?

Control "D" is an abort command used when communication sessions are not responding. I believe it sends a SIGHUP or SIGKILL signal but I'll have to double check.

Exit is the gracefull way and you always go graceful whenever possible.
Support Fatherhood - Stop Family Law
Robin Wakefield
Honored Contributor

Re: <ctrl>d and 'exit' difference?

Hi Myles,

This happens when the shell has the ignoreeof option set.

Rgds, Robin
Jose Mosquera
Honored Contributor

Re: <ctrl>d and 'exit' difference?

Hi,

Ctrl-D is a stty definition (options for a terminal port), pls check these optios by:
#stty -a

Whenever you want it you can change this assignment. i.e: if you change your "eof" definition to Ctrl-X just do:
#stty intr '^X'
So, when you check the new "intr" value you will se:
#stty -a
eof = ^x; etc, etc...

Pls chk "man stty" for more detailed info.

Rgds.
Chris Vail
Honored Contributor
Solution

Re: <ctrl>d and 'exit' difference?

The d dates back to the 'bad old days' when the user interfaces were all teletype terminals. These didn't have keys such as the F1-F12, page up, page down, arrows, or several others. Teletypes had a key and an key, and that was about it. To return the carriage, the user pressed m. To feed a line, the user pressed l.

By convention, a was how to send a (binary) 00000001 (decimal 1), b send 00000010 decimal 2), c sent 00000011 (decimal 3), and sent 000000100 (decimal 4). This held true for the entire alphabet.

Certain conventions developed: Decimal 1 was an attempt by a sender to signal a recipient. Decimal 3 was a signal that interuppted a message, and decimal 4 marked the end of the message. These rules generally hold true today. The d usually marks the end of a file or transmission. When you press the d during a shell session, the shell terminates. This can be changed with the ignoreeof option in the .profile. That requires you to type the word "exit" instead of the d. This option is there for people who display a lot of binary to their terminal, where a binary 00000100 might accidently appear.

Frankly, I don't see a lot of need for it these days. I prefer to d rather than type "exit" and , but then I'm lazy. You can get a list of the pertinent signals with "man signal" and "man kill".


Chris
Rory R Hammond
Trusted Contributor

Re: <ctrl>d and 'exit' difference?

control D ^D is (End of Transmission) in the ASCII Character Set. After logging in My stty settings sets ^D as (End of File) eof.

If you are getting a text message telling you to type exit. It sounds like your shell is trapping the signal and telling you to use "exit" instead.
trap 'echo "use exit to logout"' 4
(like the .profile) Looks like someone is trying to exit cleanly from some kind process
There are a 100 ways to do things and 97 of them are right