I am working on a linux machine. I am building a mini command line interpreter. It must terminate when the 'exit' command is received or Crtl-D is input from the keyboard, signaling end of input. How do you exit the program using Crtl-D at any point?
Asked
Active
Viewed 27 times
0
-
okay so , crtl-d is an EOF so just iterate until EOF? – Darth Sid Jul 28 '16 at 05:24
-
No no no. `stdin` is not a real file, it is a pseudo file. ctrl + d flushes immediately (without need to hit enter). So if your `read` was blocked, it returns immediately with 0 byte read which is termed as EOF here. – Mohit Jain Jul 28 '16 at 05:27