chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] pipeline.egg


From: Hans Bulfone
Subject: [Chicken-users] pipeline.egg
Date: Sun, 8 Jan 2006 17:52:46 +0100
User-agent: Mutt/1.4.2.1i

hi,

i've just finished my first extension for chicken: pipeline.egg

it allows running multiple subprocesses connected via pipes and scheme ports.

for example to backup some files with tar and encrypt them with gpg,
saving the stderr output of tar and gpg:

(let ((passphrase "foobar")
      (tar-stderr #f)
      (gpg-stdout #f)
      (gpg-stderr #f))
  (run-pipeline
   (pipeline:process
    "tar" (append '("-czf" "-") files) #f
    (pipeline:input-from-file 0 "/dev/null")
    (pipeline:output-to-pipe 1 'tar-out)
    (pipeline:output-to-port 2 (lambda (port)
                                 (set! tar-stderr (read-all port)))))

   (pipeline:process
    "gpg" (list "-o" outfile "--symmetric" "--passphrase-fd=3" "-") #f
    (pipeline:input-from-pipe 0 'tar-out)
    (pipeline:output-to-port 1 (lambda (port)
                                 (set! gpg-stdout (read-all port))))
    (pipeline:output-to-port 2 (lambda (port)
                                 (set! gpg-stderr (read-all port))))
    (pipeline:input-from-port 3 (lambda (port)
                                  (display passphrase port))))))

you can find it on http://www.nil.at/software/pipeline.egg.sexp
so far i've used it on freebsd and linux.

pipeline.egg defines the procedures fd->input-port and fd->output-port
for making scheme ports out of file descripters that do not block
other threads when read from/written to.  i've borrowed the code from
posix.scm and tcp.scm.

i'd suggest adding procedures like fd->input-port and fd->output-port
to chicken to reduce the amount of code duplication.

also, i've wondered why the ##sys#thread-block-for-i/o! call for the
output port is commented out in tcp.scm and not present at all in
posix.scm.

regards,
hans.




reply via email to

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