I am building a small shell interpreter which executes various commands, and I accomplish this by forking my process.
However, I want the child process to stop waiting for input in the standard input stream, and it does so by expecting an EOF. How do I push an EOF deliberately into that stream?
More specifically, if I am looping on this condition:
while (fgets(&input, 1024, stdin) != NULL) { // .....
How can I cause it to become false?
Not sure of what your shell is doing – but I would have thought the the way of doing this would be to close the “standard input stream” in the child side of the
fork()and then do not bother reading from it again. If you have forked a child to do something, why does it drop back into the main input handling loop.In psuedo code