Running a C# program with mono under Cent OS. There is a fifo that allows external input to go into this program.
I also have cat to accept input from the screen session the mono program is running in.
#! /bin/bash -
echo "Starting server"
mono --gc=sgen Server-CLI.exe < $fifo &
echo $$ > $PIDFILE
cat > $fifo
echo "Server stopped. Cleaning up"
rm -f $fifo
rm -f $PIDFILE
How can I make cat exit whenever the mono program exits? Right now if the mono program exits, cat is still running so the script never reaches the 2nd echo.
Save the PID of mono. Run cat in the background and save its PID. wait for the PID of mono. When this is satisfied, kill the PID of cat.
mono &
monoPID=$!
cat &
catPID=$!
wait "$monoPID"
kill "$catPID"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With