summaryrefslogtreecommitdiffstats
path: root/src/xspawn.c
Commit message (Collapse)AuthorAgeFilesLines
* build: Move feature test macros to prelude.hTavian Barnes2024-08-281-1/+0
| | | | | | This replaces the explicit CPPFLAGS list in flags.mk with just `-include src/prelude.h`, shortening our compiler command lines and allowing them to be easily documented.
* prelude: Split bfs-specific utilities into new bfs.h headerTavian Barnes2024-08-281-0/+3
|
* prelude: Rely more on __has_include()Tavian Barnes2024-08-281-1/+1
| | | | | Rather than a bunch of manual fallback macros, just provide a fallback definition that returns false.
* bfstd: New sysoption() macro to check for POSIX option runtime supportTavian Barnes2024-08-091-26/+39
| | | | | | | | | | POSIX allows optional features to be supported at compile time but not necessarily at run time by defining _POSIX_OPTION to 0 and requiring users to check sysconf(_SC_OPTION) > 0. The new sysoption() macro simplifies the check. sighook() and bfs_spawn() now check for conditional runtime support for the relevant POSIX options.
* prelude: Simplify attributesTavian Barnes2024-07-281-2/+3
|
* xspawn: Fix error message if pthread_sigmask() failsTavian Barnes2024-07-271-2/+2
|
* xspawn: Use _Fork() if availableTavian Barnes2024-07-271-0/+4
| | | | | | | This completes the workaround for bfs_spawn() hanging on FreeBSD with ASan enabled. Link: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=280318
* xspawn: Test the right macro for posix_spawn_..._addfchdir() supportTavian Barnes2024-07-161-1/+1
| | | | | | | | | | This should have been benign (just a performance regression), but FreeBSD has a bug that causes the fork()-based fallback to lock up when ASAN is enabled, due to fork() and dl_iterate_phdr(). This is not a complete workaround for that issue, since the fork() fallback may be used for other reasons. Fixes: 29ddac2 ("config: Check for posix_spawn_file_actions_addfchdir{,_np}()")
* xspawn: Check X_OK even without $PATH resolutionTavian Barnes2024-06-081-2/+11
| | | | | | | | | | Not all posix_spawn() implementations use errno to report execv() failures from the child process, as that requires either a kernel posix_spawn() implementation or a pipe to pass the error back. This should fix tests/posix/exec_nonexistent on OpenBSD and HPPA. Link: https://buildd.debian.org/status/fetch.php?pkg=bfs&arch=hppa&ver=3.3.1-1&stamp=1717489148&raw=0
* diag: New helpers to include xstrerror(errno) automaticallyTavian Barnes2024-05-171-1/+1
|
* xspawn: Mask signals before fork()Tavian Barnes2024-05-151-8/+29
| | | | This prevents signal handlers from running in the child before execve().
* config: Check for posix_spawn_file_actions_addfchdir{,_np}()Tavian Barnes2024-04-191-20/+6
|
* Rename config.h to prelude.hTavian Barnes2024-04-191-1/+1
|
* xspawn: Fix $PATH resolution on NetBSD 10Tavian Barnes2024-04-091-2/+2
|
* xspawn: Fix bfs_resolve_late() error reportingTavian Barnes2024-03-271-8/+2
|
* xspawn: Don't use posix_spawnp() on macOSTavian Barnes2024-03-271-1/+33
| | | | | | | | On macOS, posix_spawnp() resolves the executable against the $PATH *before* the file_actions are applied, contrary to the upcoming POSIX wording [1] for posix_spawn_file_actions_addfchdir(). [1]: https://www.austingroupbugs.net/view.php?id=1208#c4830
* xspawn: Refactor $PATH resolutionTavian Barnes2024-03-271-81/+240
| | | | | | | | | Technically, we should be resolving executables *after* applying the file actions. It's only safe to resolve earlier if $PATH contains no relative entries, or if there are no fchdir() actions. The new implementation resolves as early as possible, deferring to posix_spawnp() if necessary for correctness.
* xspawn: Implement bfs_spawn_addopen()Tavian Barnes2024-03-271-3/+59
|
* Re-run include-what-you-useTavian Barnes2024-03-111-1/+0
|
* xspawn: Check for _POSIX_SPAWN in bfs_spawn_addfchdir()Tavian Barnes2024-01-171-1/+1
|
* xspawn: Check for NetBSD 10 before using posix_spawn_..._fchdir()Tavian Barnes2024-01-021-1/+1
|
* config: New variadic attr(...) macroTavian Barnes2023-12-181-1/+1
|
* xspawn: Detect posix_spawn() supportTavian Barnes2023-11-191-9/+31
|
* config: New attr_maybe_unused macroTavian Barnes2023-11-151-1/+2
|
* xspawn: API tweaksTavian Barnes2023-11-151-22/+30
|
* Initial support for Cosmopolitan LibcTavian Barnes2023-11-101-1/+24
|
* xspawn: Do $PATH resolution up-frontTavian Barnes2023-11-071-21/+19
| | | | | | | | | posix_spawnp() is typically implemented like execvp(), i.e., by repeatedly trying execv() with each $PATH component until it succeeds. This is much slower than resolving the executable path up-front and then calling execv() once, so do that. Fixes: https://github.com/tavianator/bfs/pull/127#issuecomment-1795095126
* xspawn: Wrap the real posix_spawn() if possibleTavian Barnes2023-11-061-45/+122
| | | | Fixes #47.
* bfstd: New xwaitpid() wrapperTavian Barnes2023-10-311-1/+1
|
* Formatting fixesTavian Barnes2023-09-271-1/+1
|
* Use the new list macrosTavian Barnes2023-09-251-6/+5
|
* alloc: New header for memory allocation utilitiesTavian Barnes2023-06-201-1/+2
|
* list: Return the removed item from SLIST_POP()Tavian Barnes2023-05-201-3/+1
|
* config: Provide <stdalign.h> and <stdbool.h>Tavian Barnes2023-05-111-1/+0
| | | | In anticipation of C23, since those headers won't be necessary any more.
* style: Don't use tabs to indent preprocessor directivesTavian Barnes2023-05-031-1/+1
|
* list: Use macros instead of type-erased listsTavian Barnes2023-03-311-7/+8
|
* xspawn: Use list.h for the action listTavian Barnes2023-03-291-19/+17
|
* Replace license boilerplate with SPDX tagsTavian Barnes2023-01-251-15/+2
| | | | | | | And while I'm at it, remove years from copyright declarations. Link: https://spdx.dev/about/ Link: https://daniel.haxx.se/blog/2023/01/08/copyright-without-years/
* Fix includesTavian Barnes2022-11-061-0/+2
|
* bfstd: Rename from util and reorganize itTavian Barnes2022-11-061-1/+1
|
* config: Split out some of util.h into a new headerTavian Barnes2022-11-061-0/+1
|
* util: Get rid of BFS_HAS_INCLUDE() wrapper for __has_include()Tavian Barnes2022-11-061-1/+1
| | | | | | | | | Since __has_include() needs special preprocessing rules (e.g. not expanding `linux` in `__has_include(<linux/stat.h>)`, macros that expand to __has_include() do not necessarily behave correctly. Instead, we have to directly test `#if __has_include(...)`. See https://bugs.llvm.org/show_bug.cgi?id=37990 for more details.
* xspawn: Use _PATH_DEFPATH if _CS_PATH is not definedTavian Barnes2022-11-061-2/+10
| | | | | And set errno correctly if neither one is. Fixes tests/posix/exec_nopath on Android.
* util: Stub out confstr() on AndroidTavian Barnes2022-10-171-3/+5
|
* Source / Include Folder (#88)トトも2022-04-161-0/+318
Moved Source Files Into `src` Folder