mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-09 14:12:28 +00:00
Make execve() linger when it can't spoof parent
It's now possible to use execve() when the parent process isn't built by cosmo. In such cases, the current process will kill all threads and then linger around, waiting for the newly created process to die, and then we propagate its exit code to the parent. This should help bazel and others Allocating private anonymous memory is now 5x faster on Windows. This is thanks to VirtualAlloc() which is faster than the file mapping APIs. The fork() function also now goes 30% faster, since we are able to avoid the VirtualProtect() calls on mappings in most cases now. Fixes #1253
This commit is contained in:
parent
c97a858470
commit
42a3bb729a
40 changed files with 612 additions and 656 deletions
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/sigaltstack.h"
|
||||
#include "libc/calls/struct/siginfo.h"
|
||||
|
@ -40,8 +41,9 @@
|
|||
|
||||
volatile bool smashed_stack;
|
||||
|
||||
void CrashHandler(int sig) {
|
||||
void CrashHandler(int sig, siginfo_t *si, void *ctx) {
|
||||
smashed_stack = true;
|
||||
unassert(__is_stack_overflow(si, ctx));
|
||||
pthread_exit((void *)123L);
|
||||
}
|
||||
|
||||
|
@ -63,7 +65,7 @@ void *MyPosixThread(void *arg) {
|
|||
ASSERT_SYS(0, 0, sigaltstack(&ss, 0));
|
||||
sa.sa_flags = SA_SIGINFO | SA_ONSTACK; // <-- important
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_handler = CrashHandler;
|
||||
sa.sa_sigaction = CrashHandler;
|
||||
sigaction(SIGBUS, &sa, 0);
|
||||
sigaction(SIGSEGV, &sa, 0);
|
||||
exit(StackOverflow(1));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue