How do I close stdin in a shell script?
I have a misbehaving program that I need to call from my script. It exits as soon as it sees something on stdin. Is there a way to close stdin?
Solution 1:
Is there a way to close stdin?
Closing File Descriptors
n<&-
Close input file descriptor n.
0<&-
or<&-
Close stdin.
Source Chapter 20. I/O Redirection
Solution 2:
Just pipe in a program with no output:
: | misbehaving_program
Solution 3:
Found it, you can close stdin with:
exec 0<&-
Solution 4:
According to what you say, you might fix your problem by simply
pickyProgram < /dev/null