9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Lluís Batlle" <viriketo@gmail.com>
To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu>
Subject: Re: [9fans] Pipes on UNIX
Date: Thu,  6 Sep 2007 22:17:39 +0200	[thread overview]
Message-ID: <45219fb00709061317x594e82a6vb43d136767f245ab@mail.gmail.com> (raw)
In-Reply-To: <599f06db0709060906t745766b4h2bc4fc499a16b417@mail.gmail.com>

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.

As I want the CGI to accept input from almost any length, I need a
"pipe buffer" big enough.

Then, based on Gorka suggestion (which I didn't understand as a
9pserver ;), I finally agreed on the easiest solution wrapping the CGI
with a sh script:
#!/bin/sh
head -n 10000000 > inputfile   # limiting the disk ussage to 10MB, raw cutting.
mycgi < inputfile
#EOF

That's all. I will not write any "superpipe" program, or any 9pserver,
because at the end I need the disk. The sh wrapper works well enough.

Thank you for your help in this non-plan9-related problem! Simply the
unicon documentation pointed to something strange in named pipes which
I couldn't check anywhere. :)

Regards,
Lluís

2007/9/6, Gorka Guardiola <paurea@gmail.com>:
> I wrote it without coffee... would be more like:
>
> generate_data > input &
> data_eater < output
>
> :-).
>
> And input and output can come from a stupid fileserver like pipefs...
> or pipebackedbyaharddiskfs :-).
> --
> - curiosity sKilled the cat
>


  reply	other threads:[~2007-09-06 20:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-06 13:04 Lluís Batlle
2007-09-06 13:57 ` sqweek
2007-09-06 14:02   ` Lluís Batlle
2007-09-06 14:12     ` sqweek
2007-09-06 14:42       ` Lluís Batlle
2007-09-06 14:47         ` Gorka Guardiola
2007-09-06 14:57           ` Lluís Batlle
2007-09-06 15:52           ` ron minnich
2007-09-06 16:06             ` Gorka Guardiola
2007-09-06 20:17               ` Lluís Batlle [this message]
2007-09-06 20:33                 ` erik quanstrom
2007-09-06 20:40                   ` Lluís Batlle
2007-09-06 21:51                 ` Charles Forsyth
2007-09-06 14:04 ` Enrico Weigelt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45219fb00709061317x594e82a6vb43d136767f245ab@mail.gmail.com \
    --to=viriketo@gmail.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).