For some reason, this bash script never gets to echo "after cat"
, but does get past echo "before cat"
.
rm pipe
mkfifo pipe
echo "before server"
cd backend
node bin/www > pipe &
cd ..
echo "before cat"
server_output=$(cat pipe) # seems to get hung up here
echo "after cat"
echo "$server_output"
# [bash to check the server output here and print it conditionally]
I understand that pipes need to have both ends open in order to not block, but I thought I’ve done this by including the ‘&’ symbol in node bin/www > pipe &
.
I’ve tried using head
(with --lines=1
and without) instead of cat
to no avail.