/usr/share/scsh-0.6/misc/pipe.scm is in scsh-common-0.6 0.6.7-8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | ; Copyright (c) 1993-1999 by Richard Kelsey and Jonathan Rees. See file COPYING.
; Scheme analogues of Posix popen() and pclose() library calls.
(define (call-with-mumble-pipe input?)
(lambda (command proc)
(call-with-values pipe
(lambda (pipe-for-read pipe-for-write)
(let ((winner (if input? pipe-for-read pipe-for-write))
(loser (if input? pipe-for-write pipe-for-read))
(pid (fork)))
(if (= pid 0)
(dynamic-wind
(lambda () #f)
(lambda ()
(close winner)
(let ((foo (if input? 1 0)))
(close foo)
(if (not (= (dup loser) foo))
(error "dup lost" loser foo)))
(execv "/bin/sh"
(vector "sh" "-c" command)))
(lambda () (exit 1))))
;; (write `(pid = ,pid)) (newline)
(close loser)
(let* ((channel (open-channel winner
(if input?
(enum open-channel-option
raw-input-channel)
(enum open-channel-option
raw-output-channel))))
(port (if input?
(input-channel->port channel 1024)
(output-channel->port channel 1024))))
(call-with-values (lambda () (proc port))
(lambda vals
(if input?
(close-input-port port)
(close-output-port port))
;; (display "Waiting.") (newline)
(call-with-values (lambda () (waitpid pid 0))
(lambda (pid status)
;; (write `(status = ,status)) (newline)
(apply values vals)))))))))))
(define call-with-input-pipe
(call-with-mumble-pipe #t))
(define call-with-output-pipe
(call-with-mumble-pipe #f))
|