From 1cf08f39294f771ba867bd2f51aaa9bbeb3d00a9 Mon Sep 17 00:00:00 2001 From: Daniel Eischen Date: Wed, 18 Apr 2001 12:40:30 +0000 Subject: [PATCH] Reinstall the alternate signal stack after a fork. PR: 25110 Tested by: knu --- lib/libc_r/uthread/uthread_fork.c | 12 +++++++++++- lib/libkse/thread/thr_fork.c | 12 +++++++++++- lib/libpthread/thread/thr_fork.c | 12 +++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/lib/libc_r/uthread/uthread_fork.c b/lib/libc_r/uthread/uthread_fork.c index 4437d886a80..a2aabbe149b 100644 --- a/lib/libc_r/uthread/uthread_fork.c +++ b/lib/libc_r/uthread/uthread_fork.c @@ -32,6 +32,7 @@ * $FreeBSD$ */ #include +#include #include #include #include @@ -112,7 +113,16 @@ _fork(void) else if (_pq_init(&_readyq) != 0) { /* Abort this application: */ PANIC("Cannot initialize priority ready queue."); - } else { + } else if ((_thread_sigstack.ss_sp == NULL) && + ((_thread_sigstack.ss_sp = malloc(SIGSTKSZ)) == NULL)) + PANIC("Unable to allocate alternate signal stack"); + else { + /* Install the alternate signal stack: */ + _thread_sigstack.ss_size = SIGSTKSZ; + _thread_sigstack.ss_flags = 0; + if (__sys_sigaltstack(&_thread_sigstack, NULL) != 0) + PANIC("Unable to install alternate signal stack"); + /* * Enter a loop to remove all threads other than * the running thread from the thread list: diff --git a/lib/libkse/thread/thr_fork.c b/lib/libkse/thread/thr_fork.c index 4437d886a80..a2aabbe149b 100644 --- a/lib/libkse/thread/thr_fork.c +++ b/lib/libkse/thread/thr_fork.c @@ -32,6 +32,7 @@ * $FreeBSD$ */ #include +#include #include #include #include @@ -112,7 +113,16 @@ _fork(void) else if (_pq_init(&_readyq) != 0) { /* Abort this application: */ PANIC("Cannot initialize priority ready queue."); - } else { + } else if ((_thread_sigstack.ss_sp == NULL) && + ((_thread_sigstack.ss_sp = malloc(SIGSTKSZ)) == NULL)) + PANIC("Unable to allocate alternate signal stack"); + else { + /* Install the alternate signal stack: */ + _thread_sigstack.ss_size = SIGSTKSZ; + _thread_sigstack.ss_flags = 0; + if (__sys_sigaltstack(&_thread_sigstack, NULL) != 0) + PANIC("Unable to install alternate signal stack"); + /* * Enter a loop to remove all threads other than * the running thread from the thread list: diff --git a/lib/libpthread/thread/thr_fork.c b/lib/libpthread/thread/thr_fork.c index 4437d886a80..a2aabbe149b 100644 --- a/lib/libpthread/thread/thr_fork.c +++ b/lib/libpthread/thread/thr_fork.c @@ -32,6 +32,7 @@ * $FreeBSD$ */ #include +#include #include #include #include @@ -112,7 +113,16 @@ _fork(void) else if (_pq_init(&_readyq) != 0) { /* Abort this application: */ PANIC("Cannot initialize priority ready queue."); - } else { + } else if ((_thread_sigstack.ss_sp == NULL) && + ((_thread_sigstack.ss_sp = malloc(SIGSTKSZ)) == NULL)) + PANIC("Unable to allocate alternate signal stack"); + else { + /* Install the alternate signal stack: */ + _thread_sigstack.ss_size = SIGSTKSZ; + _thread_sigstack.ss_flags = 0; + if (__sys_sigaltstack(&_thread_sigstack, NULL) != 0) + PANIC("Unable to install alternate signal stack"); + /* * Enter a loop to remove all threads other than * the running thread from the thread list: