In Bash, I learned that the endingsignal can be changed by heredocument. But by default how can Isignal the end of stdin input?I happened to find that with cat andchardet, their stdin inputs can besignaled as finished by Ctrl+d. ButI seems to remember that Ctrl+d andCtrl+c are similar to endingexecution of a running command. Soam I wrong?
How to signal the end of stdin input
command line;terminal;signals
Ctrl+D, when typed at the start of a line on a terminal, signifies the end of the input. This is not a signal in the unix sense: when an application is reading from the terminal and the user presses Ctrl+D, the application is notified that the end of the file has been reached (just like if it was reading from a file and had passed the last byte).Ctrl+C does send a signal, SIGINT. By default SIGINT (the interrupt signal) kills the foreground application, but the application can catch the signal and react in some different way (for example, the shell itself catches the signal and aborts the line you've begun typing, but it doesn't exit, it shows a new prompt and waits for a new command line).You can change the characters associated with end-of-file and SIGINT with the stty command, e.g. stty eof a would make a the end-of-file character, and stty intr ^- would disable the SIGINT character. This is rarely useful.