[plt-scheme] system and system/exit-code under Mac OS X

From: Jens Axel Soegaard (jensaxel at soegaard.net)
Date: Mon Oct 29 13:21:38 EDT 2007

Hi all,

I have a problem with "system" under Mac OS X 10.4 and
wish to know whether I my expectations are wrong,
or whether there is a bug somewhere.

I have an object file that prints a little
on standard out, and then returns with the
exit code 0.

Using "system" from (lib "process.ss") which
synchronously executes I get this result:

   > (system "./test/test-1193675986-324921376.o")

The #f means that the exit-code was non-zero, so
I tried system/exit-code and got:

   > (system/exit-code "./test/test-1193675986-324921376.o")

As a sanity test I tried the thing in Perl:

  $ perl -e "printf(system(\"./test/test-1193675986-324921376.o\\"))"
  <the output>

The 0 is the exit status.

Executed directly in the shell I get:

   $ ./test/test-1193675986-324921376.o
   <the output>
   $ echo $?

so at least the shell and Perl results are consistent.

The function "system" in (lib "process.ss") is defined as:

   (define (system str)
     (if (eq? (system-type) 'macos)
	(subprocess #f #f #f "by-id" str)
	(apply system* (shell-path/args "system" str))))

And the documentation for subprocess says that it
executes the command asynchronously, which seems fishy,
but maybe the "by-id" initiates some magic?

Jens Axel Søgaard

Posted on the users mailing list.