Problems with pipe(...); using select(...);


 
Thread Tools Search this Thread
Top Forums Programming Problems with pipe(...); using select(...);
# 1  
Old 01-12-2006
Problems with pipe(...); using select(...);

Hello all,

My problem is as follows:

I'm trying to wake up a select(...); using a pipe fd. This should be rather straightforward, but I cannot get it to work. Perhaps you guys could give me a few tips.

My wakeup function looks like this:

Code:
STATIC void net_trig_wr()
{
   /* write a dummy to wake up net thread */
   write(net_pipefd, _T("TRIG"), 4);
}


This pipe is created using:

Code:
   int pipe_set[2];
   ALLEGE(pipe(pipe_set) == 0);
   net_pipefd = pipe_set[1];
   FD_SET(pipe_set[0], &net_rd_set);


And the net_rd_set is the set select uses:

Code:
 ALLEGE((res = select(maxfd+1, &net_rd_set, &net_wr_set, NULL, NULL)) != -1);


Of course the maxfd is set to:

Code:
 maxfd = pipe_set[0];


It should be noted net_trig_wr(); is called from another thread (created using POSIX-threads) than the select(...) operates in.

I've attached the entire net.c file (as net.txt) in this document. So if you want to have a look at it to help me further. Feel free to get inspired by my code also (if there is anything to get inspired by).

Any tips would be usefull!

/ Henrik, Sweden

(For the intressted, im actually rewriting a Java-server I've done for www.betapet.com which is a free swedish scrabble-site)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to ignore Pipe in Pipe delimited file?

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)
Discussion started by: rohit_shinez
13 Replies

2. Programming

Problems with pipe IPC

I'm currently studying IPC, I have a first program A: Do an exec for B and wait B: Receive through a fifo a string from a third program "C" and have to resend it to A I was thinking to open a pipe in A before the exec, then passing fd to B as an argument if(pipe(fd)==-1){ ... (1 Reply)
Discussion started by: cifz
1 Replies

3. Shell Programming and Scripting

Replace pipe with Broken Pipe

Hi All , Is there any way to replace the pipe ( | ) with the broken pipe (0xA6) in unix (1 Reply)
Discussion started by: saj
1 Replies

4. Boot Loaders

Reboot and Select Proper Boot device or insert Boot media in select Boot device and press a key

Hello, I have kubuntu on my laptop and now I decided to switch to Windows 7. I made the bios settings properly (first choice is boot from cd\vd) but I see the error " reboot and select proper Boot device or insert Boot media in select Boot device and press a key " I have tried CD and... (0 Replies)
Discussion started by: rpf
0 Replies

5. Programming

Problems with select

Is select only supposed to report state changes on an FD's, state, whether or not it had pending input available in the first place? I've got a situation where select() repeatedly reports no FD's ready for stdin when there's lots of data available. And if it only reports changes, how is this... (2 Replies)
Discussion started by: Corona688
2 Replies

6. UNIX Desktop Questions & Answers

Wall, Write, select users, pipe a text file, HELP Before I'm Bald!

OK... I'm fairly new to unix having the admin handed to me on a platter w/almost no training. However, being a programmer, I do pick up things fairly easily, but this one is getting the best of me. I have a unix server that runs multiple versions of the same ERP system, hand crafted for our... (1 Reply)
Discussion started by: chimodel
1 Replies

7. UNIX for Dummies Questions & Answers

Threads with pipe and select?

Hi. I just found this site while searching for some info on a problem and thought I'd see if anyone else knows the answer. I have two threads that are connected by a pipe. Thread A can write to the pipe and Thread B can read the data from the pipe. My problem is that when I use select() in... (3 Replies)
Discussion started by: willil
3 Replies

8. UNIX for Dummies Questions & Answers

Pipe SQL select statement results to script

Hello I would like to perform a select from a oracle table and return those values to my shell script For example: site=head -1 $infile | cut -c1-15 | awk '{printf "s%", $0} sqlplus -s /nolog |& #Open pipe to sql select col1, col2, col3, col4 from oracle_table where col5 =... (6 Replies)
Discussion started by: houtakker
6 Replies

9. Shell Programming and Scripting

how to select a value randomly

on my desktop i am using the kde rotating desktop image option. this rotates images randomly every half hour. now, i would like to write an html file which will have an inline frame with some text, maybe system messages, or my friends live journal thati read alot, or unix.com! however, i dont want... (1 Reply)
Discussion started by: norsk hedensk
1 Replies

10. UNIX for Advanced & Expert Users

'make' problems (compliation problems?)

I'm trying to compile and install both most recent version of 'make' and the most recent version of 'openssh' on my Sparc20. I've run into the following problems... and I don't know what they mean. Can someone please help me resolve these issues? I'm using the 'make' version that was... (5 Replies)
Discussion started by: xyyz
5 Replies
Login or Register to Ask a Question