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
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,
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:
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 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.
among the below socket programming api's, please let me know which are blocking and non-blocking.
socket
accept
bind
listen
write
read
close (2 Replies)
Hi guys,
I need to know how i can ignore Pipe '|' if Pipe is coming as a column in Pipe delimited file
for eg:
file 1:
xx|yy|"xyz|zzz"|zzz|12...
using below awk command
awk 'BEGIN {FS=OFS="|" } print $3
i would get xyz
But i want as :
xyz|zzz to consider as whole column... (13 Replies)
Hi
I am starting to practice nmap for my own education.
Now I created two host in virtual box.
Bot are scientific linux, one in installed as web server and the other as developing station.
I tried to run nmap on so I did nmap on their IP address, I got an answer that ip is down or that... (8 Replies)
I know how to add signal to a set. But what if I want to add 2 or 3 signals to the set.
I know I can use sigaddset (&set,SIGBUS)....but what if I want to add SIGBUS and SIGALRM at once. Do i have to do it like this..
sigaddset (&set,SIGBUS);
sigaddset (&set,SIGALRM);
Is there another way to... (0 Replies)
Hi Folks
I have been debugging a script that is called every thirty seconds. Basically it is doing a ps, well two actually, one to file (read by the getline below) and the other into a pipe. The one into the pipe is: -
V_SYSVPS=/usr/sysv/bin/ps
$V_SYSVPS -p$PIDLIST -o$PSARGS... (0 Replies)
Hi!!
I have a problem reading from a fifo pipe in shell script.
The idea is simple, I have a C program with two pipe files:
An input pipe I use to send commands in shell script to the C program (echo "command" > input.pipe)
An output pipe that I read the result of the command also in... (4 Replies)
I've got a legit DHCP server on my network. I've got a 3550 as my VTP server providing 4 vlans to 4 2950 switches. If somebody were to plug into one of those vlans with a DHCP server configured then it would throw off my whole network. How could i block the DHCP server that could plug into the... (2 Replies)
I'm in highschool. They blocked my favorite site. How do I disable websense without getting caught on that particular webpage? Is it even possible? *twitch* I would also like to get as much UNIX for beginners information, so if someone might point me in the right direction so I don't have to read... (1 Reply)