I’m looking for a variant of
/dev/null that causes
read to block forever, rather than returning EOF immediately. Does such a device exist?
I could probably create a named pipe (via
mkfifo) to achieve the desired effect, but I’d rather not have to deal with unlinking the FIFO at the end of the script.
For context, I want to wait for an RPC server to quit. To avoid polling, I open a connection via netcat:
netcat localhost 12345
The connection will be closed automatically when the server closes. Unfortunately, when running the command via SSH, stdin is set to
/dev/null and so netcat exits immediately after sending EOF instead of waiting for the connection to close.
netcat -d (don’t wait for stdin) has a bug? on macOS and spins hot, meaning the solution is actually worse than polling at a reasonable interval.
I have a solution to this problem—hooking stdin up to a pipe—but I am specifically interested in the question as stated out of pure curiosity.