I'm a little confused, I had this working yesterday, but it just stopped accepting the redirected stdin, almost magically.
set -m
mkfifo inputfifo
mkfifo inputfifo_helper
((while true; do cat inputfifo; done) > inputfifo_helper)&
trap "rm -f inputfifo inputfifo_helper java.pid; kill $!" EXIT
exec 3<&0
(cat <&3 > inputfifo)&
NOW=$(date +"%b-%d-%y-%T")
if ! [ -d "logs" ]; then
mkdir logs
fi
if [ -f "server.log" ]; then
mv server.log logs/server-$NOW.log
fi
java <inputfifo_helper -jar $SERVER_FILE & echo $! > java.pid && fg
This was running fine, I could echo things to inputfifo and the app got it, and I could type directly into it's console as well. It even worked through screen. Absolutely nothing code-wise has changed, but the redirected stdin has stopped working. I tried changing the file descriptor to 9, or even 127, but neither fixed it.
Am I forgetting something? Is there a specific reason it broke and no longer works?
(I'm using this instead of sending input to the screen itself because I start the screen detached and it refuses to receive input unless it's been attached to atleast once, I don't know if this is a bug or intended)