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 17:10:22 -0500
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux)

Kevin Ryde <address@hidden> wrote:
> address@hidden (Paul Jarc) writes:
>> Is it possible to guarantee that the child will not trigger garbage
>> collection?
>
> Probably not.  A good reason to do it in C.

Even in C, avoiding garbage collection is probably impossible.  At
some level, the child has to allocate the argv array that will be
passed to execve().

> (Though it could be argued that it ought to be possible to this sort
> of thing safely at the scheme level, somehow.)

I think my Scheme procedure is safe.

> Incidentally, looking at glibc sysdeps/posix/system.c, it seems to
> ignore SIGINT and SIGQUIT in the parent while running the child.  I'm
> not up with the standards or conventions on this, but for maximum
> compatibility I suppose a "system*" might like to do the same.

I believe that's geared toward applications running on a tty, with the
assumption that if the user interrupts the child, the parent is
supposed to keep running.  This may or may not be what an application
wants, so we should provide both varieties.  Given system*/nowait as
before, we can have (with whatever names):

(define (system*/no-ignore-signals . args)
  (cdr (waitpid (apply system*/nowait args))))
(define (system*/ignore-signals . args)
  (let* ((pid (apply system*/nowait args))
         (old-int  (sigaction SIGINT  SIG_IGN))
         (old-quit (sigaction SIGQUIT SIG_IGN))
         (status (cdr (waitpid (apply system*/nowait args)))))
    (sigaction SIGINT  (car old-int)  (cdr old-int))
    (sigaction SIGQUIT (car old-quit) (cdr old-quit))
    status))


paul




reply via email to

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