I want to write to something (a named pipe, a socket, idk) and if there is reader listening to the socket, the data will go to the reader(s), otherwise it just gets dumped to /dev/null. Is there some way to do that?

if I write my own unix domain socket server that listens on the socket, then I can accomplish this, but I am wondering if the naked filesystem can do this somehow?

it would be like a named pipe and if the

mkfifo ifnoreadersdump

while true; do
  cat ifnoreadersdump | while read line; do
     if reader; then
        echo "$line" > reader
        echo "$line" > /dev/null  # unnecessary, but for illustrative purposes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.