diff options
-rw-r--r-- | libguile/simpos.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/libguile/simpos.c b/libguile/simpos.c index 5e6005448..356d78673 100644 --- a/libguile/simpos.c +++ b/libguile/simpos.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2003 Free Software +/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2003, 2004 Free Software * Foundation, Inc. * * This library is free software; you can redistribute it and/or @@ -158,12 +158,26 @@ SCM_DEFINE (scm_system_star, "system*", 0, 0, 1, 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_DEFINE (scm_system_star, "system*", 0, 0, 1, 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)); |