Write more tests and improve kill() on Windows

This commit is contained in:
Justine Tunney 2023-10-13 02:22:48 -07:00
parent b81a1bd9a8
commit d458642790
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
6 changed files with 183 additions and 13 deletions

View file

@ -48,6 +48,7 @@
#include "libc/sysv/consts/prot.h"
#include "libc/sysv/consts/sig.h"
#include "libc/sysv/consts/sock.h"
#include "libc/temp.h"
#include "libc/x/xasprintf.h"
#include "net/https/https.h"
#include "third_party/mbedtls/net_sockets.h"
@ -399,18 +400,16 @@ bool ShouldRunInParallel(void) {
}
int SpawnSubprocesses(int argc, char *argv[]) {
const char *tpath;
sigset_t chldmask, savemask;
int i, ws, pid, tmpfd, *pids, exitcode;
int i, ws, pid, *pids, exitcode;
struct sigaction ignore, saveint, savequit;
char *args[5] = {argv[0], argv[1], argv[2]};
// create compressed network request ahead of time
CHECK_NE(-1, (tmpfd = open(
(tpath = _gc(xasprintf(
"%s/runit.%d", firstnonnull(getenv("TMPDIR"), "/tmp"),
getpid()))),
O_WRONLY | O_CREAT | O_TRUNC, 0755)));
const char *tmpdir = firstnonnull(getenv("TMPDIR"), "/tmp");
char *tpath = _gc(xasprintf("%s/runit.XXXXXX", tmpdir));
int tmpfd = mkstemp(tpath);
CHECK_NE(-1, tmpfd);
CHECK(SendRequest(tmpfd));
CHECK_NE(-1, close(tmpfd));