diff --git a/NEWS b/NEWS index dafad95c4..dae2e0ff7 100644 --- a/NEWS +++ b/NEWS @@ -60,6 +60,14 @@ capability to search for "libfoo" as "msys-foo.dll" on MSYS. The load-foreign-library option #:rename-on-cygwin? has been changed to #:host-type-rename?, and handles both Cygwin and MSYS. +** Make piped-process and system* available on systems without fork + +Now that piped-process and system* are implemented in terms of +`posix_spawn', they can be made available on systems without fork(). +Note that currently Guile does use fork in piped-process to set exit +codes, so piped-process on systems without fork will have a different +behavior with regards to exit codes. + * Performance improvements ** `copy-file` now relies on `sendfile` rather than a read/write loop diff --git a/libguile/posix.c b/libguile/posix.c index 3d38bc310..6e9fd4b7c 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1529,7 +1529,6 @@ SCM_DEFINE (scm_spawn_process, "spawn", 2, 0, 1, } #undef FUNC_NAME -#ifdef HAVE_FORK static int piped_process (pid_t *pid, SCM prog, SCM args, SCM from, SCM to) #define FUNC_NAME "piped-process" @@ -1630,11 +1629,13 @@ scm_piped_process (SCM prog, SCM args, SCM from, SCM to) /* Create a dummy process that exits with value 127 to mimic the previous fork + exec implementation. TODO: This is a compatibility shim to remove in the next stable series. */ +#ifdef HAVE_FORK pid = fork (); if (pid == -1) SCM_SYSERROR; if (pid == 0) _exit (127); +#endif /* HAVE_FORK */ } return scm_from_int (pid); @@ -1690,7 +1691,6 @@ SCM_DEFINE (scm_system_star, "system*", 0, 0, 1, return scm_from_int (status); } #undef FUNC_NAME -#endif /* HAVE_FORK */ #ifdef HAVE_UNAME SCM_DEFINE (scm_uname, "uname", 0, 0, 0, @@ -2566,13 +2566,12 @@ SCM_DEFINE (scm_gethostname, "gethostname", 0, 0, 0, #endif /* HAVE_GETHOSTNAME */ -#ifdef HAVE_FORK static void scm_init_popen (void) { scm_c_define_gsubr ("piped-process", 2, 2, 0, scm_piped_process); } -#endif /* HAVE_FORK */ + void scm_init_posix () @@ -2690,10 +2689,10 @@ scm_init_posix () #ifdef HAVE_FORK scm_add_feature ("fork"); +#endif /* HAVE_FORK */ scm_add_feature ("popen"); scm_c_register_extension ("libguile-" SCM_EFFECTIVE_VERSION, "scm_init_popen", (scm_t_extension_init_func) scm_init_popen, NULL); -#endif /* HAVE_FORK */ }