mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 16:28:30 +00:00
Overhaul process spawning
This commit is contained in:
parent
99dc1281f5
commit
26e254fb4d
96 changed files with 1848 additions and 1541 deletions
|
@ -1,28 +0,0 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2023 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/dce.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
TEST(close, stdout) {
|
||||
if (!IsWindows()) return;
|
||||
close(1);
|
||||
fprintf(stderr, "hi\n");
|
||||
}
|
|
@ -19,6 +19,7 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
@ -69,7 +70,10 @@ TEST(dup, bigNumber) {
|
|||
|
||||
#ifdef __x86_64__
|
||||
TEST(dup, clearsCloexecFlag) {
|
||||
static bool once;
|
||||
int ws;
|
||||
ASSERT_FALSE(once);
|
||||
once = true;
|
||||
ASSERT_SYS(0, 0, close(creat("file", 0644)));
|
||||
ASSERT_SYS(0, 3, open("file", O_RDWR | O_CLOEXEC));
|
||||
ASSERT_NE(-1, (ws = xspawn(0)));
|
||||
|
@ -79,7 +83,7 @@ TEST(dup, clearsCloexecFlag) {
|
|||
(char *const[]){GetProgramExecutableName(), "boop", 0});
|
||||
_exit(127);
|
||||
}
|
||||
ASSERT_EQ(72, WEXITSTATUS(ws));
|
||||
ASSERT_EQ(72 << 8, ws);
|
||||
ASSERT_SYS(0, 0, close(3));
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -57,6 +57,17 @@ TEST(write, badMemory_efault) {
|
|||
ASSERT_SYS(EFAULT, -1, write(1, (void *)1, 1));
|
||||
}
|
||||
|
||||
TEST(write, brokenPipe_raisesSigpipe) {
|
||||
int fds[2];
|
||||
SPAWN(fork);
|
||||
signal(SIGPIPE, SIG_DFL);
|
||||
ASSERT_SYS(0, 0, pipe(fds));
|
||||
ASSERT_SYS(0, 1, write(4, "x", 1));
|
||||
ASSERT_SYS(0, 0, close(3));
|
||||
write(4, "x", 1);
|
||||
TERMS(SIGPIPE);
|
||||
}
|
||||
|
||||
TEST(write, brokenPipe_sigpipeIgnored_returnsEpipe) {
|
||||
int fds[2];
|
||||
SPAWN(fork);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue