chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Interaction of subprocess and condition handling


From: Lassi Kortela
Subject: Re: [Chicken-users] Interaction of subprocess and condition handling
Date: Sat, 20 Jul 2019 00:45:00 +0300
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

OK, I perused the chicken-core git repo. posixunix.scm defines the 'process' procedure. It's a wrapper for the 'process-impl' procedure in the same file. process-impl does a lot of setup, then:

  (chicken.process#process-fork
    (lambda ()
      ;; ...set up input and output pipes...
      (chicken.process#process-execute cmd args env)))

And chicken.process#process-execute is also defined in the same file. I presume it's the execve() wrapper. The execve() error is handled in it as follows:

   (when (fx= r -1)
     (posix-error #:process-error 'process-execute
                  "cannot execute process" filename))

If 'process-execute' is run from within 'process', then 'process-execute' is running in the forked child process, and the above error is also signaled in that child process instead of the parent.

Since the code that caused the bug for me had my own 'condition-case' exception handler wrapped around the 'process' call, it would catch an exception in the child process, not in the parent.

And since normal control flow proceeds after a 'condition-case' exception handler has run, the forked child would continue running my Scheme program concurrently with the parent!

Probably you should change the implementation of 'process' so it calls a version of 'process-execute' that's specialized to run inside a child process forked with the sole purpose of "execve() or die trying" :)



reply via email to

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