I have a question for you, how could I implement a catch of CTRL+D? I have a program, which reads strings untill is pressed CTRL+D, and I don't wanna have ^D in a console :(. After I press CTRL+D I have to press ENTER, and only after that my program stops :(. Have any ideas?
Keep reading until the EOF condition is reached.
My program works, and I use EOF, but the problem is, that I have to catch a signal, not char, smth like CTRL+Z in Windows.
Originally Posted by laserlight
Aye, but the signal triggers EOF.
Ctrl-D should have an effect immediately if it is the first character on a line. If there are other characters before it on the line, you need to hit enter before the program will see it.
Originally Posted by midnight
Beyond that, if you want greater control over how Ctrl-D is handled, you need to reprogram the terminal device using calls like ioctl() and tcsetattr().
(None of it has anything to do with signals).