When the terminal is not in raw mode, if I write some text, this text will be placed in a buffer (I think it's called the line buffer), after that if I press Ctrl+D, the content of this buffer will be sent to my application.

But what happens when I press Ctrl+D and the terminal is in raw mode (i.e. what I write in the terminal is not buffered but rather it's sent directly to my application), will some ASCII code (probably 0x04) be sent to my application?

  • 1
    Is this the third CTRL-D question of the day? Is this a homework assignment? Be honest. Dup? – RubberStamp Nov 3 '17 at 15:37
  • @RubberStamp It's the second Ctrl+D question. And no, it's not a homework. – user258851 Nov 3 '17 at 15:44

You can check that with strace

In shell 1:

$ echo $$

In shell 2:

strace -p 1234 -f

In shell 1:

$ stty raw
$ cat
[type something including ^D]

In Shell 2 you can see:

[pid 12345] read(0, "\4", 131072)       = 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.