summaryrefslogtreecommitdiff
path: root/libguile/posix.c
diff options
context:
space:
mode:
authorMichael Gran <spk121@yahoo.com>2023-06-20 15:38:54 -0700
committerMichael Gran <spk121@yahoo.com>2025-03-22 21:32:45 -0700
commit9c86c5936e6eda65e4e38e95d582ee0d2360af47 (patch)
tree5a45c172bf27e6dafd82d8c79ae4fb438cf86ffa /libguile/posix.c
parent87402c849eda1a75df7882b3c04ba08f33848da4 (diff)
downloadguile-9c86c5936e6eda65e4e38e95d582ee0d2360af47.tar.gz
Allow piped-process and system* to exist when fork is undefined
piped-process only uses fork to match legacy behavior, but on systems that never had fork, there is no need to match that behavior. piped-process and system* can be provided without fork. * libguile/posix.c (piped_process): allow function definition without HAVE_FORK, but stub out internal dummy process with HAVE_FORK (restore_sigaction, scm_dynwind_sigaction, scm_system_star): don't require HAVE_FORK (scm_init_popen): don't require HAVE_FORK (scm_init_posix): don't require HAVE_FORK to add posix feature or register popen extension
Diffstat (limited to 'libguile/posix.c')
-rw-r--r--libguile/posix.c9
1 files changed, 4 insertions, 5 deletions
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 */
}