4

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.

1 Answer 1

5

You can connect the program's standard-input to /dev/null:

./myprogram < /dev/null &
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I tried it, % ./myprogram < /dev/null & this works on a console terminal but when run it from inside my script it doesnot work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.