9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
[parent not found: <<8ccc8ba40912070814o2f2c7eb9s5887a31810eab12e@mail.gmail.com>]
* Re: [9fans] ideas for helpful system io functions
@ 2009-12-07 14:41 Francisco J Ballesteros
  2009-12-07 15:11 ` roger peppe
  0 siblings, 1 reply; 46+ messages in thread
From: Francisco J Ballesteros @ 2009-12-07 14:41 UTC (permalink / raw)
  To: 9fans

I think he wants copyfile + a kproc.

On 07/12/2009, at 15:37, rogpeppe@gmail.com wrote:

> 2009/12/7 Sam Watkins <sam@nipl.net>:
>> I meant for example if a process is reading from its stdin a open
>> file 'A' and
>> writing to stdout the input of a pipe 'B', rather than looping and
>> forwarding
>> data it may simply "join" these two fds, and exit.  The OS will
>> then do what is
>> necessary to make sure the data can travel from A to B (and/or vice
>> versa) with
>> the minimum effort needed.
>
> i'm not sure how you think this would work.
>
> a file descriptor is essentially a passive object - it responds
> to read, write, etc requests on it, but it doesn't do anything
> of its own accord.
>
> if i do:
>
> fd1 := open("/foo1", ORDWR);
> fd2 := open("/foo2", ORDWR);
> fd3 := fdjoin(fd1, fd2);
>
> what is going to happen?
> something has got to initiate the requests to actually
> shift the data, and it's not clear which direction the
> data will flow.
>
> this is an optimisation, right? what parts of the current system
> could be speeded up by the use of this primitive?
>
> [/mail/box/nemo/msgs/200912/452]



^ permalink raw reply	[flat|nested] 46+ messages in thread
[parent not found: <<20091207120652.GB16320@knaagkever.ueber.net>]
[parent not found: <<20091205202420.855AD5B77@mail.bitblocks.com>]
[parent not found: <<20091205081032.GJ8759@nipl.net>]
[parent not found: <<alpine.BSF.2.00.0912042210290.81688@legolas.yyc.orthanc.ca>]
[parent not found: <<alpine.BSF.2.00.0912042029370.66255@legolas.yyc.orthanc.ca>]
* [9fans] ideas for helpful system io functions
@ 2009-12-05  3:17 Sam Watkins
  2009-12-05  3:36 ` Lyndon Nerenberg
  2009-12-05 18:16 ` Tim Newsham
  0 siblings, 2 replies; 46+ messages in thread
From: Sam Watkins @ 2009-12-05  3:17 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

I have two ideas for io functions that I think would be helpful, they are
alternative options to solve a simple problem really.  I don't know if plan 9
has any functions like these already.

For example, when starting a CGI script for a POST request, a httpd reads the
http headers but typically also the first little bit of the POST data.  I would
like to be able to simply fork and exec the CGI script, but this missing POST
data means this will not work.  The httpd has to write the POST data to a
temporary file, or else use a temporary "socketpair" or similar to communicate
with the CGI script.  Hopefully you know what I mean.

Another example, a little server that allows connections on a single port 443
for https and ssh.  Ideally after reading the "GET" or ssh banner, it can just
exec whichever server is needed (or fork and exec something like netcat).  but
in fact due to this "already read some data" problem, it has to stay alive and
copy the data in and out from the other server.

I can see two possible solutions for this, both of which would be useful in my
opinion:

  - an "unread" function, like ungetc, which allows a program to put back some
    data that was already read to the OS stdin buffer (not the stdio buffer).
    This might be problematic if there is a limit to the size of the buffers.
  - a "join" function (or something) which allows a process to unify/join its
    file descriptors (e.g. before exiting).  For example join(0, 1) would
    connect STDIN directly to STDOUT.  The OS might need to interpose a
    "sendfile"-like copy mechanism, or collapse a pipe or socket, to make this
    work nicely.  This would allow a process to fork, write some data to
    STDOUT, join(0, 1) and exit, solving this problem I mentioned.

what do you think?  I doubt these ideas are original, but I think they would be useful and I don't know of any implementation in unix or any other OS.

Sam



^ permalink raw reply	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2010-01-05 15:53 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <<20091205194741.0697D5B76@mail.bitblocks.com>
2009-12-05 20:03 ` [9fans] ideas for helpful system io functions erik quanstrom
2009-12-05 20:24   ` Bakul Shah
     [not found] <<8ccc8ba40912070814o2f2c7eb9s5887a31810eab12e@mail.gmail.com>
2009-12-07 16:24 ` erik quanstrom
2009-12-07 16:48   ` Francisco J Ballesteros
2009-12-07 14:41 Francisco J Ballesteros
2009-12-07 15:11 ` roger peppe
     [not found] <<20091207120652.GB16320@knaagkever.ueber.net>
2009-12-07 12:19 ` erik quanstrom
     [not found] <<20091205202420.855AD5B77@mail.bitblocks.com>
2009-12-05 20:27 ` erik quanstrom
2009-12-05 20:59   ` Bakul Shah
2009-12-06  7:45     ` Sam Watkins
2009-12-05 20:30 ` erik quanstrom
     [not found] <<20091205081032.GJ8759@nipl.net>
2009-12-05 13:51 ` erik quanstrom
     [not found] <<alpine.BSF.2.00.0912042210290.81688@legolas.yyc.orthanc.ca>
2009-12-05 13:26 ` erik quanstrom
2009-12-05 14:22   ` Sam Watkins
2009-12-05 17:47     ` Skip Tavakkolian
2009-12-05 17:56       ` Skip Tavakkolian
     [not found] <<alpine.BSF.2.00.0912042029370.66255@legolas.yyc.orthanc.ca>
2009-12-05  4:47 ` erik quanstrom
2009-12-05  5:09   ` Lyndon Nerenberg
2009-12-05  5:11     ` Lyndon Nerenberg
2009-12-05  8:10   ` Sam Watkins
2009-12-05 11:44     ` Francisco J Ballesteros
2009-12-05 16:32       ` ron minnich
2009-12-05 17:01         ` Francisco J Ballesteros
2009-12-05 17:09           ` ron minnich
  -- strict thread matches above, loose matches on Subject: below --
2009-12-05  3:17 Sam Watkins
2009-12-05  3:36 ` Lyndon Nerenberg
2009-12-05  3:56   ` Sam Watkins
2009-12-05  4:03     ` Lyndon Nerenberg
2009-12-05 18:16 ` Tim Newsham
2009-12-05 18:24   ` Tim Newsham
2009-12-05 19:47     ` Bakul Shah
2009-12-07 12:24       ` roger peppe
2009-12-07 12:32         ` Charles Forsyth
2009-12-07 12:35           ` Francisco J Ballesteros
2009-12-07 13:42             ` Charles Forsyth
2009-12-07 16:10             ` erik quanstrom
2009-12-07 16:14               ` Francisco J Ballesteros
2009-12-07 14:13         ` Sam Watkins
2009-12-07 14:36           ` roger peppe
2009-12-07 19:11             ` Nathaniel W Filardo
2009-12-07 21:03               ` roger peppe
2009-12-08 12:51           ` matt
2009-12-07 12:06     ` Mechiel Lukkien
2009-12-07 12:31       ` roger peppe
2010-01-05 13:48     ` Enrico Weigelt
2010-01-05 15:53       ` Steve Simon

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).