diff --git a/libc/calls/struct/sigset.h b/libc/calls/struct/sigset.h index 3d783c47a..09faa3118 100644 --- a/libc/calls/struct/sigset.h +++ b/libc/calls/struct/sigset.h @@ -4,19 +4,21 @@ COSMOPOLITAN_C_START_ typedef uint64_t sigset_t; -int sigaddset(sigset_t *, int) paramsnonnull(); -int sigdelset(sigset_t *, int) paramsnonnull(); -int sigemptyset(sigset_t *) paramsnonnull(); -int sigfillset(sigset_t *) paramsnonnull(); -int sigandset(sigset_t *, const sigset_t *, const sigset_t *) paramsnonnull(); -int sigorset(sigset_t *, const sigset_t *, const sigset_t *) paramsnonnull(); -int sigisemptyset(const sigset_t *) paramsnonnull() nosideeffect; -int sigismember(const sigset_t *, int) paramsnonnull() nosideeffect; -int sigcountset(const sigset_t *) paramsnonnull() nosideeffect; -int sigprocmask(int, const sigset_t *, sigset_t *); -int sigsuspend(const sigset_t *); -int sigpending(sigset_t *); -int pthread_sigmask(int, const sigset_t *, sigset_t *); +/* clang-format off */ +int sigaddset(sigset_t *, int) libcesque paramsnonnull(); +int sigdelset(sigset_t *, int) libcesque paramsnonnull(); +int sigemptyset(sigset_t *) libcesque paramsnonnull(); +int sigfillset(sigset_t *) libcesque paramsnonnull(); +int sigandset(sigset_t *, const sigset_t *, const sigset_t *) libcesque paramsnonnull(); +int sigorset(sigset_t *, const sigset_t *, const sigset_t *) libcesque paramsnonnull(); +int sigisemptyset(const sigset_t *) libcesque paramsnonnull() nosideeffect; +int sigismember(const sigset_t *, int) libcesque paramsnonnull() nosideeffect; +int sigcountset(const sigset_t *) libcesque paramsnonnull() nosideeffect; +int sigprocmask(int, const sigset_t *, sigset_t *) dontthrow; +int sigsuspend(const sigset_t *) dontthrow; +int sigpending(sigset_t *) libcesque; +int pthread_sigmask(int, const sigset_t *, sigset_t *) dontthrow; +/* clang-format on */ COSMOPOLITAN_C_END_ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGSET_H_ */ diff --git a/libc/system/systemvpe.c b/libc/system/systemvpe.c index e44ed8d66..1165d45c3 100644 --- a/libc/system/systemvpe.c +++ b/libc/system/systemvpe.c @@ -52,9 +52,8 @@ int systemvpe(const char *prog, char *const argv[], char *const envp[]) { int pid, wstatus; char pathbuf[PATH_MAX + 1]; sigset_t chldmask, savemask; - if (!(exe = commandv(prog, pathbuf, sizeof(pathbuf)))) { + if (!(exe = commandv(prog, pathbuf, sizeof(pathbuf)))) return -1; - } sigemptyset(&chldmask); sigaddset(&chldmask, SIGINT); sigaddset(&chldmask, SIGQUIT); @@ -62,7 +61,7 @@ int systemvpe(const char *prog, char *const argv[], char *const envp[]) { sigprocmask(SIG_BLOCK, &chldmask, &savemask); if (!(pid = vfork())) { sigprocmask(SIG_SETMASK, &savemask, 0); - execve(prog, argv, envp); + execve(exe, argv, envp); _Exit(127); } else if (pid == -1) { wstatus = -1; diff --git a/test/libc/system/BUILD.mk b/test/libc/system/BUILD.mk index 0e1545776..ef1a6036d 100644 --- a/test/libc/system/BUILD.mk +++ b/test/libc/system/BUILD.mk @@ -94,6 +94,17 @@ o/$(MODE)/test/libc/system/trace_test.dbg: \ $(APE_NO_MODIFY_SELF) @$(APELINK) +o/$(MODE)/test/libc/system/systemvpe_test.dbg: \ + $(TEST_LIBC_SYSTEM_DEPS) \ + o/$(MODE)/test/libc/system/systemvpe_test.o \ + o/$(MODE)/test/libc/system/system.pkg \ + o/$(MODE)/test/libc/proc/life.zip.o \ + $(LIBC_TESTMAIN) \ + $(CRT) \ + $(APE_NO_MODIFY_SELF) + @$(APELINK) + + o/$(MODE)/test/libc/system/popen_test.zip.o: private ZIPOBJ_FLAGS += -B o/$(MODE)/test/libc/system/popen_test.dbg.zip.o: private ZIPOBJ_FLAGS += -B diff --git a/test/libc/system/systemvpe_test.c b/test/libc/system/systemvpe_test.c new file mode 100644 index 000000000..bcbc5a30c --- /dev/null +++ b/test/libc/system/systemvpe_test.c @@ -0,0 +1,34 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│ vi: set et ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi │ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 2024 Justine Alexandra Roberts Tunney │ +│ │ +│ Permission to use, copy, modify, and/or distribute this software for │ +│ any purpose with or without fee is hereby granted, provided that the │ +│ above copyright notice and this permission notice appear in all copies. │ +│ │ +│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ +│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ +│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ +│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ +│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ +│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ +│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ +│ PERFORMANCE OF THIS SOFTWARE. │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/calls.h" +#include "libc/cosmo.h" +#include "libc/runtime/runtime.h" +#include "libc/testlib/testlib.h" + +void SetUpOnce(void) { + testlib_enable_tmp_setup_teardown(); +} + +TEST(systemvpe, test) { + ASSERT_SYS(0, 0, mkdir("bin", 0755)); + ASSERT_SYS(0, 0, setenv("PATH", "bin", true)); + testlib_extract("/zip/life", "bin/life", 0755); + ASSERT_SYS(0, 42 << 8, + systemvpe("life", (char *[]){"life", 0}, (char *[]){0})); +}