Non-blocking write to a fifo
Hi,
I'm fairly new to bash scripting being mainly a Java programmer...
I have an applications which reads some input from a named pipe to receive administrative commands. Everything works fine but the command which writes to the pipe blocks if my application is not running.
I would like to be able to test or have a return code or something other then blocking if there is nothing to read the pipe.
Currently, I am using a really simple shell script to send the command to the pipe, I'm only doing a printf "command\n" > pipename.
I've read in the man page that I hould receive a SIGPIPE if the reading process is non existing, but even when I try to "trap trapfunc SIGPIPE" the printf command still hangs and I have to kill the script by hand.
I would like to be able to handle this gracefully because if the application is not responding, it may be because it is actually crashed (a thread crashed ungracefully) but is still running so I would need to kill it instead.
Well, I hope I'm not too confusing with those explanation, thanks to all
Dan
Last edited by droussel; 05-22-2003 at 01:44 PM.
|