Write more tests for signal handling

There's now a much stronger level of assurance that signaling on Windows
will be atomic, low-latency, low tail latency, and shall never deadlock.
This commit is contained in:
Justine Tunney 2024-09-21 05:24:56 -07:00
parent 0e59afb403
commit dd8c4dbd7d
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
19 changed files with 407 additions and 75 deletions

View file

@ -29,6 +29,7 @@
#include "libc/nt/enum/pageflags.h"
#include "libc/nt/files.h"
#include "libc/nt/memory.h"
#include "libc/nt/process.h"
#include "libc/nt/runtime.h"
#include "libc/nt/thunk/msabi.h"
#ifdef __x86_64__
@ -42,11 +43,16 @@ __msabi extern typeof(CreateFileMapping) *const __imp_CreateFileMappingW;
__msabi extern typeof(MapViewOfFileEx) *const __imp_MapViewOfFileEx;
__msabi extern typeof(SetEndOfFile) *const __imp_SetEndOfFile;
__msabi extern typeof(SetFilePointer) *const __imp_SetFilePointer;
__msabi extern typeof(GetEnvironmentVariable)
*const __imp_GetEnvironmentVariableW;
__msabi textwindows char16_t *__sig_process_path(char16_t *path, uint32_t pid,
int create_directories) {
// Generates C:\ProgramData\cosmo\sig\x\y.pid like path
__msabi textwindows dontinstrument char16_t *__sig_process_path(
char16_t *path, uint32_t pid, int create_directories) {
char16_t buf[3];
char16_t *p = path;
*p++ = 'C'; // C:\ProgramData\cosmo\sig\x\y.pid
uint32_t vlen = __imp_GetEnvironmentVariableW(u"SYSTEMDRIVE", buf, 3);
*p++ = vlen == 2 ? buf[0] : 'C';
*p++ = ':';
*p++ = '\\';
*p++ = 'P';