scsh-users
[Top] [All Lists]

Re: usefulness of scsh for web CGIs

To: scsh@martigny.ai.mit.edu
Subject: Re: usefulness of scsh for web CGIs
From: holly@random.pc-labor.uni-bremen.de (Holger Duerer - Esperanto parolata)
Date: 22 May 1996 18:37:47 +0200
Organization: Zentrum fuer angewandte Informationstechnologien der Universitaet Bremen
>>>>> "me" == Holger Duerer <holly@random.ZAIT.Uni-Bremen.DE> writes:
  >>>>> On 21 May 1996 08:06:30 -0400, shivers@ai.mit.edu (Olin Shivers) said:
  Olin>    From: Hannes Haug <Hannes.Haug@Student.Uni-Tuebingen.de>
  Olin>    Subject: Re: usefulness of scsh for web CGIs

  Olin>    [...] The possibility to pass file descriptors to scsh
  Olin>    (not yet possible) would make the whole thing trivial.

  Olin> Unfortunately, passing file descriptors to non-children is not
  Olin> standard Unix.
  Olin>     -Olin

  me> Ups, it is not?  What are the exact requirements to be `standard
  me> Unix'?  W.R.Stevens mentions in his `Adv. Programming in the UNIX
  me> Env.' that from SVR3.2 on passing of open file descriptors is
  me> supported.  BSD did this (correctly) from 4.3 on.  Which of today's
  me> Unices does not support it?


OK, so far I received two personal mails questioning this statement by
me (these might be courtesy copies of follow-ups, but our news feed is
rather slow getting new postings, so I'll just follow-up myself).

>From my reading (I never did it, only heard it from at least two or
three sources -- (about the BSD method that is)) the non-obvious
(ie. not inheriting from your parent) method of doing the passing
isn't all that hard, once you know how to do it. :-)


The general idea is that you establish a connection (Stevens calls it
a stream) between the two processes.  On this you can then transmit an
open fd between these processes.

Unfortunately you seem to have to distinguish between SYSV and BSD.
SYSV uses standard named pipes that are modified by some arcane calls
to ioctl(), fattach() etc. which I haven't tried to understand yet.  A
fd is passed with an ioctl() with arg I_SENDFD / I_RECFD.

On BSD you use Unix-domain sockets and sendmsg() / recvmsg() where
you have to fiddle with the msghdr structure.

(It becomes a bit easier when you want to pass fd's upstream, i.e. to
your parent process.  For that, you don't need the extra work to
acquire the transport fd but could use some inherited pipe.)


More details in chapter 15 of [1].  The code from that book is
available on several FTP sites too, so you could even save the typing
work.


Cheers,
        Holger

-------------
[1] W. Richard Stevens: ``Advanced Programming in the UNIX
    Environment''.  Addison-Wesley. 1992.  0-201-56317-7.

-- 
------------------------------------------------------------------------------
Holger D"urer                                          Tel.: ++49 421 218-2452
Universit"at Bremen                                    Fax.: ++49 421 218-2720
ZKW  und  FB 3 -- Informatik     
Postfach 330 440                                 <H.Duerer@ZAIT.Uni-Bremen.DE>
D - 28334 Bremen            <http://www.zait.uni-bremen.de/Duerer/Holger.html>

<Prev in Thread] Current Thread [Next in Thread>