[Top][All Lists]

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

Re: Support for (system '("echo" "foo" "bar"))

From: Paul Jarc
Subject: Re: Support for (system '("echo" "foo" "bar"))
Date: Fri, 31 Oct 2003 15:37:21 -0500
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux)

Kevin Ryde <address@hidden> wrote:
> As a suggestion, I think a variation that just returned the child pid
> would be nice (or threw an execption for an exec failure).

(define (system*/nowait . args)
  (let* ((p (pipe))
         (pid (primitive-fork)))
    (if (zero? pid)
       (lambda ()
         (close-port (car p))
         (fcntl (cdr p) F_SETFD FD_CLOEXEC)
         (apply execlp (car args) args))
       (lambda exception
         (write exception (cdr p))
         (force-output (cdr p))
         (raise SIGKILL)))
        (close-port (cdr p))
        (let ((exception (read (car p))))
          (close-port (car p))
          (if (not (eof-object? exception))
            (apply throw exception)

I'd still prefer the argv list as a single Scheme argument, though,
since it saves an "apply" when the list is dynamically constructed.


reply via email to

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