diff options
author | midipix <writeonce@midipix.org> | 2024-03-16 15:34:44 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2024-03-16 15:34:44 +0000 |
commit | c8ac943463470e1486a061a65943b2be859ba2df (patch) | |
tree | 479b8e81265020bf02b447b0cf9cd827290aa8b4 /src | |
parent | 7ff9431e77e9966c19c8fcda06a0de2a750efe09 (diff) | |
download | slibtool-c8ac943463470e1486a061a65943b2be859ba2df.tar.bz2 slibtool-c8ac943463470e1486a061a65943b2be859ba2df.tar.xz |
simple process creation: midipix targets: utilize the fast and robust vfork().
Diffstat (limited to 'src')
-rw-r--r-- | src/arbits/slbt_archive_syminfo.c | 3 | ||||
-rw-r--r-- | src/fallback/slbt_archive_import_mri.c | 2 | ||||
-rw-r--r-- | src/host/slbt_host_params.c | 3 | ||||
-rw-r--r-- | src/internal/slibtool_spawn_impl.h | 8 | ||||
-rw-r--r-- | src/util/slbt_dump_machine.c | 2 |
5 files changed, 14 insertions, 4 deletions
diff --git a/src/arbits/slbt_archive_syminfo.c b/src/arbits/slbt_archive_syminfo.c index 8b013ab..5a96ab9 100644 --- a/src/arbits/slbt_archive_syminfo.c +++ b/src/arbits/slbt_archive_syminfo.c @@ -20,6 +20,7 @@ #include "slibtool_ar_impl.h" #include "slibtool_driver_impl.h" #include "slibtool_dprintf_impl.h" +#include "slibtool_spawn_impl.h" #include "slibtool_snprintf_impl.h" #include "slibtool_errinfo_impl.h" @@ -112,7 +113,7 @@ static int slbt_obtain_nminfo( if ((fdout = openat(fdcwd,output,O_CREAT|O_TRUNC|O_WRONLY,0644)) < 0) return SLBT_SYSTEM_ERROR(dctx,output); - if ((pid = fork()) < 0) { + if ((pid = slbt_fork()) < 0) { close(fdout); return SLBT_SYSTEM_ERROR(dctx,0); } diff --git a/src/fallback/slbt_archive_import_mri.c b/src/fallback/slbt_archive_import_mri.c index 4a8eaed..320d6d1 100644 --- a/src/fallback/slbt_archive_import_mri.c +++ b/src/fallback/slbt_archive_import_mri.c @@ -137,7 +137,7 @@ int slbt_util_import_archive_mri( if (pipe(fd)) return SLBT_SYSTEM_ERROR(dctx,0); - if ((pid = fork()) < 0) { + if ((pid = slbt_fork()) < 0) { close(fd[0]); close(fd[1]); return SLBT_SYSTEM_ERROR(dctx,0); diff --git a/src/host/slbt_host_params.c b/src/host/slbt_host_params.c index 94456e2..cd9ad87 100644 --- a/src/host/slbt_host_params.c +++ b/src/host/slbt_host_params.c @@ -15,6 +15,7 @@ #include <slibtool/slibtool.h> #include "slibtool_driver_impl.h" +#include "slibtool_spawn_impl.h" #include "slibtool_errinfo_impl.h" #include "slibtool_visibility_impl.h" #include "slibtool_ar_impl.h" @@ -63,7 +64,7 @@ static void slbt_spawn_ar(char ** argv, int * ecode) *ecode = 127; - if ((pid = fork()) < 0) { + if ((pid = slbt_fork()) < 0) { return; } else if (pid == 0) { diff --git a/src/internal/slibtool_spawn_impl.h b/src/internal/slibtool_spawn_impl.h index 93df1cd..aa4ea35 100644 --- a/src/internal/slibtool_spawn_impl.h +++ b/src/internal/slibtool_spawn_impl.h @@ -30,6 +30,12 @@ #include <spawn.h> #endif +#ifdef __midipix__ +static pid_t slbt_fork(void) {return vfork();} +#else +static pid_t slbt_fork(void) {return fork();} +#endif + static inline int slbt_spawn( struct slbt_exec_ctx * ectx, bool fwait) @@ -56,6 +62,8 @@ static inline int slbt_spawn( #endif + (void)slbt_fork; + if (pid < 0) { ectx->pid = pid; ectx->exitcode = errno; diff --git a/src/util/slbt_dump_machine.c b/src/util/slbt_dump_machine.c index f7a2a07..1b42211 100644 --- a/src/util/slbt_dump_machine.c +++ b/src/util/slbt_dump_machine.c @@ -70,7 +70,7 @@ int slbt_util_dump_machine( if (pipe(fd)) return -1; - if ((pid = fork()) < 0) { + if ((pid = slbt_fork()) < 0) { close(fd[0]); close(fd[1]); return -1; |