guile-devel
[Top][All Lists]
Advanced

[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 12:05:49 -0500
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux)

Rob Browning <address@hidden> wrote:
> {
>   if (SCM_NULLP (cmds))
>     SCM_WRONG_TYPE_ARG (1, cmds);
>
>   if (SCM_CONSP (cmds))
...
>   else
>     SCM_WRONG_TYPE_ARG (1, SCM_CAR (cmds));

This doesn't look right - you're looking at (car cmds) when cmds is
not a cons.  How about:
{
  if (! SCM_CONSP (cmds))
    SCM_WRONG_TYPE_ARG (1, cmds);
  ...
}

That should catch the null case too.  Or, to get the behavior Kevin
described:

(define (system* . args)
  (flush-all-ports)
  (let* ((p (pipe))
         (pid (primitive-fork)))
    (if (zero? pid)
      (catch
       'system-error
       (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))
         (primitive-exit)))
      (begin
        (close-port (cdr p))
        (let* ((exception (read (car p)))
               (status (cdr (waitpid pid))))
          (close-port (car p))
          (if (not (eof-object? exception))
            (apply throw exception)
            status))))))


paul




reply via email to

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