Non-blocking pipe

Hello,
Would this be an acceptable way of creating a non-blocking pipe.
Basically I want to create kind of a server client arch.
This code would be in the server, and I don't want to have to wait for
clients to read before moving on to the next client. One problem I
can see is if a client leaves/dies and never reads from the pipe(but I
could have some trap/cleanup stuff in the clients for that).

# assigning fd 3 to the pipe
echo "exec 3>myfifo && echo 'a' >&3 && echo 'b' >&3 && echo 'c' >&3 &&
exec 3>&-" | at now

Chris.

A UNIX domain socket is essentially a FIFO with the extra properties you want -- the ability for multiple clients to connect to one server. See this link for details.

Thanks for the info. I would like to keep this in shell script(bash). It's kind of a learning project trying to learn all I can about shell scripting for bash. So I'm trying to build a little shell game.
Thanks,

Chris.

The && will cause the shell to wait before running the command after it, and should any of them fail, none of the ones after it will run. && is a conditional, it's not a background statement. Also, is there any particular reason that string of commands is all in one line? And what is 'echo exec' for, did you mean for that to be without the echo?

I don't think there's any point trying to open it as a FD in the shell if you're trying to save time, since the shell will wait for the reader to open the pipe anyway. Once it does, all three processes will get the same pipe, which I doubt is what you want. at which point all three processes will get copies of the same pipe, not queue up.

This sort of code, on the other hand, will wait for the pipe, launch a process, then immediately wait on the pipe again without waiting for the launched process to finish:

echo a > fifo &
echo b > fifo &
echo c > fifo &

Corona688,
Thanks for the info.

I think my line wrapped here when I pasted it which made it a little confusing. I was echoing out that string of commands and piping them into at. I thought that because they were being piped into at that I needed to keep them in the same statement because otherwise the second echo command wouldn't know about the fd assigned to the pipe, but I pretty sure your right that I don't need a fd descriptor. Also, with how I want to do develop this I don't really need to send multiple lines to the fifo without reopening the reader.

Thanks again,

Chris.