--- simpos.c.~1.55.~ 2004-03-31 11:57:03.000000000 +1000 +++ simpos.c 2004-04-01 07:09:02.000000000 +1000 @@ -158,12 +158,26 @@ oldquit = scm_sigaction (sigquit, sig_ign, SCM_UNDEFINED); pid = fork (); - if (pid == -1) - SCM_SYSERROR; - else if (pid) + if (pid == 0) { - int wait_result; - int status; + /* child */ + execvp (SCM_STRING_CHARS (SCM_CAR (args)), execargv); + scm_remember_upto_here_1 (args); + SCM_SYSERROR; + /* not reached. */ + return SCM_BOOL_F; + } + else + { + /* parent */ + int wait_result, status, save_errno; + + save_errno = errno; + free (execargv); + errno = save_errno; + if (pid == -1) + SCM_SYSERROR; + SCM_SYSCALL (wait_result = waitpid (pid, &status, 0)); if (wait_result == -1) SCM_SYSERROR; scm_sigaction (sigint, SCM_CAR (oldint), SCM_CDR (oldint)); @@ -171,14 +185,6 @@ scm_remember_upto_here_2 (oldint, oldquit); return SCM_MAKINUM (0L + status); } - else - { - execvp (SCM_STRING_CHARS (SCM_CAR (args)), execargv); - scm_remember_upto_here_1 (args); - SCM_SYSERROR; - /* not reached. */ - return SCM_BOOL_F; - } } else SCM_WRONG_TYPE_ARG (1, SCM_CAR (args));