![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reading from blocking fifo pipe in shell script | victorin | Shell Programming and Scripting | 4 | 05-08-2007 12:39 PM |
| Blocking a Single IP | Phobos | UNIX for Dummies Questions & Answers | 4 | 04-28-2005 12:09 AM |
| blocking DHCP | byblyk | IP Networking | 2 | 03-16-2005 12:06 AM |
| School Blocking | Satine | IP Networking | 1 | 02-07-2005 05:07 PM |
| blocking domains | tamemi | UNIX for Dummies Questions & Answers | 1 | 04-16-2003 08:13 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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. Last edited by Neo; 02-09-2009 at 05:25 PM.. Reason: removed self promoting link of new member |
|
||||
|
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: Code:
echo a > fifo & echo b > fifo & echo c > fifo & |
|
||||
|
Corona688,
Thanks for the info. Quote:
Thanks again, Chris. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|