From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <4bddb19f76168d998a8085d9554d3b48@quanstro.net> To: 9fans@cse.psu.edu Subject: Re: [9fans] Pipes on UNIX From: erik quanstrom Date: Thu, 6 Sep 2007 16:33:39 -0400 In-Reply-To: <45219fb00709061317x594e82a6vb43d136767f245ab@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: b9e441b8-ead2-11e9-9d60-3106f5b1d025 > I better explain my problem. :) > I have a CGI for Apache. I wrote it in C, and it simply parses text > from a html textarea, giving another html in output. I made it as a > state machine which outputs and outputs according to the input > characters. > > Apache communicates with the CGI process with two pipes linked to the > process' stdin and stdout. > But I think that apache code is like this: > while() > { > read(socket,buffer) > write(pipe_process1, buffer) > } > while() > { > read(pipe_process2, buffer) > write(socket,buffer) > } > > Therefore, if I had a CGI similar to 'cat' (and I have), it would > deadlock due to the pipe_process2 not being read by apache if it gets > filled, the process blocks, and then pipe_process1 gets filled. no, you wouldn't. i believe the problem is the cgi and apache disagree on the termination condition. make sure you close the fd 0 when you are done reading. - erik