mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-06 22:43:34 +00:00
parent
fde03f8487
commit
8db646f6b2
4 changed files with 62 additions and 16 deletions
|
@ -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_ */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
34
test/libc/system/systemvpe_test.c
Normal file
34
test/libc/system/systemvpe_test.c
Normal file
|
@ -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}));
|
||||
}
|
Loading…
Reference in a new issue