scsh-users
[Top] [All Lists]

Re: run/port for input

To: scsh@zurich.csail.mit.edu
Subject: Re: run/port for input
From: stktrc <stktrc@yahoo.com>
Date: 07 Nov 2003 10:28:54 +0100
Sender: news <news@sea.gmane.org>
ZHAO Wei <zhaoway@public1.ptt.js.cn> writes:

> Can I have something as nice as (run/port ...) but for input instead
> of for output? Thank you!

Below is a modification of run/port taken from the SCSH sources to
produce an input port instead.

(define (run/inport* thunk)
  (receive
   (r w) (pipe)
   (fork (lambda ()
           (close w)
           (move->fdes r 0)
           (with-current-input-port* r thunk)))
   (close r)
   w))

(define-syntax run/inport
  (syntax-rules ()
    ((_ . epf) (run/inport* (lambda () (exec-epf . epf))))))


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