[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: open-input-output-process, open-input-output-pipe

From: Rob Browning
Subject: Re: open-input-output-process, open-input-output-pipe
Date: 19 Mar 2001 12:56:53 -0600
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Mikael Djurfeldt <address@hidden> writes:

> I'd find something like the patch below useful.  The procedures
> below return a pair of an input and output port instead of the
> input-output port which is stated in the comment.  How would one go
> about implementing it as intended, i.e. with an input-output-port?

I agree that having something like this would be useful since I wrote
something very similar lately :>.

I originally implemented it with one io-port too, but for some reason
(probably a misunderstanding on my part), never did quite get it to
work right.  In the end I settled on returning (list pid to-child-port
from-child-port stderr-port).  This seems perhaps better than just one
two-way port anyway, if you want to handle stderr.  (Actually, right
now, in my code, stderr isn't really hooked up, yet).

There's also a "cleanup-sub-process" script that might be useful to
some, but probably not generally.  It just tries to make sure a child
is cleaned up when you're finished with it, getting increasingly
cranky if the child doesn't cooperate.

In any case it looks like you used some tricks I didn't even know
about, and that I should probably adopt.  Given that, your version is
probably the better one.  In particular:

> +    (setvbuf (cdr from) _IONBF)
> +    (setvbuf (cdr to) _IONBF)

I didn't do this because I wanted to leave the "chunking" up to the
code generating the output for the child (having them call force when
appropriate).  Also, is there any need for the call on the port coming
from the child?  Doesn't "(read port)" and friends do this?

> +          (set-batch-mode?! #t)
> +          (close-all-ports-except (cdr from) (car to))

Didn't know about these, but they're obviously appropriate...

> +          (move->fdes (cdr from) 1)
> +          (move->fdes (car to) 0)

I was using dup->fdes.

> +    (pipe-guardian (car port))

I didn't realize we had pipe-guardians.  Is there any documentation

> +    (hashq-set! port/pid-table (car port) (cdr port/pid))

Another bit I didn't know I needed to add.  Is there documentation for
how this is supposed to be handled?


Rob Browning <address@hidden> PGP=E80E0D04F521A094 532B97F5D64E3930

reply via email to

[Prev in Thread] Current Thread [Next in Thread]