mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-01 08:48:29 +00:00
Polyfill SIGCHLD on the New Technology
redbean will now cleanup child processes properly. New accounting information is available too, such as page faults and memory usage. The way it works is Cosmopolitan Libc samples the process collection on entry into read() and poll() to see if SIGCHLD needs to be raised. This change also fixes an issue with chibicc /tmp cleanup. There was also a regression in MODE=dbg because STL needed ASAN runtime support.
This commit is contained in:
parent
c23b6ecc31
commit
393ca4be40
18 changed files with 182 additions and 44 deletions
|
@ -27,6 +27,7 @@
|
|||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/asancodes.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/log/backtrace.internal.h"
|
||||
#include "libc/log/internal.h"
|
||||
|
@ -1256,6 +1257,14 @@ void *__asan_get_current_fake_stack(void) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void __sanitizer_annotate_contiguous_container(long beg, long end, long old_mid,
|
||||
long new_mid) {
|
||||
// the c++ stl uses this
|
||||
// TODO(jart): make me faster
|
||||
__asan_unpoison(beg, new_mid - beg);
|
||||
__asan_poison(new_mid, end - new_mid, kAsanHeapOverrun);
|
||||
}
|
||||
|
||||
void __asan_install_malloc_hooks(void) {
|
||||
HOOK(hook_free, __asan_free);
|
||||
HOOK(hook_malloc, __asan_malloc);
|
||||
|
|
|
@ -17,20 +17,12 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define ShouldUseMsabiAttribute() 1
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/nexgen32e/vendor.internal.h"
|
||||
#include "libc/nt/console.h"
|
||||
#include "libc/nt/process.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/nt/thunk/msabi.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/sysv/consts/nr.h"
|
||||
|
||||
uint32_t __winmainpid;
|
||||
const char kConsoleHandles[2] = {kNtStdInputHandle, kNtStdOutputHandle};
|
||||
|
||||
/**
|
||||
* Terminates process, ignoring destructors and atexit() handlers.
|
||||
*
|
||||
|
@ -45,11 +37,6 @@ const char kConsoleHandles[2] = {kNtStdInputHandle, kNtStdOutputHandle};
|
|||
privileged noinstrument noasan noubsan wontreturn void _Exit(int exitcode) {
|
||||
int i;
|
||||
STRACE("_Exit(%d)", exitcode);
|
||||
if (SupportsWindows() && GetCurrentProcessId() == __winmainpid) {
|
||||
for (i = 0; i < 2; ++i) {
|
||||
SetConsoleMode(GetStdHandle(kConsoleHandles[i]), __ntconsolemode[i]);
|
||||
}
|
||||
}
|
||||
if ((!IsWindows() && !IsMetal()) || (IsMetal() && IsGenuineCosmo())) {
|
||||
asm volatile("syscall"
|
||||
: /* no outputs */
|
||||
|
|
|
@ -20,11 +20,15 @@
|
|||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/nt/console.h"
|
||||
#include "libc/nt/process.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
uint32_t __winmainpid;
|
||||
const char kConsoleHandles[2] = {kNtStdInputHandle, kNtStdOutputHandle};
|
||||
|
||||
/**
|
||||
* Exits process faster.
|
||||
*
|
||||
|
@ -35,6 +39,11 @@ wontreturn void quick_exit(int exitcode) {
|
|||
int i;
|
||||
const uintptr_t *p;
|
||||
STRACE("quick_exit(%d)", exitcode);
|
||||
if (SupportsWindows() && GetCurrentProcessId() == __winmainpid) {
|
||||
for (i = 0; i < 2; ++i) {
|
||||
SetConsoleMode(GetStdHandle(kConsoleHandles[i]), __ntconsolemode[i]);
|
||||
}
|
||||
}
|
||||
if (weaken(fflush)) {
|
||||
weaken(fflush)(0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue