Reputation: 141
I have a program "myprogram" and it waits for a enter key when run on console. After we press somekey it exits. I want to run this myprogram in background and ignore stdin input.
I have a smaple script,
sample.sh script
------
./myprogram &
exit 0
------
but when I run,
%sh sample.sh
some how myprogram gets some inputs from stdin and exits.. I want to stop it from getting any input from stdin so even after sample.sh exits myprogram continue to run.
Please suggest how I can update sample.sh script to achieve this.
Upvotes: 4
Views: 2698
Reputation: 183554
You can connect the program's standard-input to /dev/null
:
./myprogram < /dev/null &
Upvotes: 5