-2

Is it true to say that CTRL+D stops input execution while CTRL+C stops output displaying (as plain data, without execution)?

1

No, it is not true.

However, it is true to say that Ctrl+D signals an End of Transmission (EOT) event which will generally cause a program reading input to close the input file descriptor.

Ctrl+D is used for this because its place on the ASCII table corresponds to the analogous End of File control character, even though the actual EOF control character is not actually transmitted in this case.

Pressing Ctrl+C will generally (it's configurable with stty) generate an interrupt signal (SIGINT) which will be delivered to the processes that are in the current terminal (see man kill; man 3 tcgetpgrp).

  • 2
    I'm curious as to the reasoning behind the downvotes to this answer to the question. How would you who have downvoted this improve this answer? Edits or constructive comments are always welcome. – DopeGhoti Feb 5 at 19:25
  • There are a few more steps to Ctrl+D, but I don't feel it's important in this context. The process reading will get a zero back from read(), signalling an End of File state on that fd. That in turn is due to other things. – Kusalananda Feb 5 at 19:52
  • 1
    @mosvy I feel this comment isn't helping. How can the short question be improved IYO? – JohnDoea Feb 8 at 5:24
  • 1
    @mosvy demagogia means loss of time for all of us. I was really serious in my intention to ask how to IYO the difference could be best learned in a question here. I you think the difference should be learned by deepening the learning of each keyboard shortcut, this was indeed helping. – JohnDoea Feb 8 at 18:59
  • 1
    Digressions aside, I'm hopeful that my tweaks to the answer both clarify what is actually happening and do not diminish from the simplicity of the larger point, which is that it would not be true to say that ^C and ^D terminate stdout and stdin respectively, as asked at the outset of this adventure. – DopeGhoti Feb 8 at 20:14

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.