Follow kernel change, restore signal mask correctly by using a command

of kse_thr_interrupt.
This commit is contained in:
David Xu 2004-10-07 13:52:18 +00:00
parent 84e0b075f6
commit e897f51327
2 changed files with 34 additions and 42 deletions

View File

@ -39,30 +39,26 @@ __weak_reference(_execve, execve);
int
_execve(const char *name, char *const *argv, char *const *envp)
{
sigset_t omask;
struct kse_execve_args args;
struct pthread *curthread;
kse_critical_t crit;
int saved_errno;
int ret;
/*
* When exec'ing, set the kernel signal mask to the thread's
* signal mask to satisfy POSIX requirements. We have to enter
* a critical region so that the kernel thread doesn't get
* changed out from under us after setting the signal mask.
*/
curthread = _get_curthread();
crit = _kse_critical_enter();
__sys_sigprocmask(SIG_SETMASK, &curthread->sigmask, &omask);
ret = __sys_execve(name, argv, envp);
if (!_kse_isthreaded())
ret = __sys_execve(name, argv, envp);
else {
/*
* When exec'ing, set the kernel signal mask to the thread's
* signal mask to satisfy POSIX requirements.
*/
curthread = _get_curthread();
args.sigmask = curthread->sigmask;
args.sigpend = curthread->sigpend;
args.path = (char *)name;
args.argv = (char **)argv;
args.envp = (char **)envp;
args.reserved = NULL;
ret = kse_thr_interrupt(NULL, KSE_INTR_EXECVE, (long)&args);
}
/*
* If something went wrong, set the signal mask back but don't
* destroy errno.
*/
saved_errno = errno;
__sys_sigprocmask(SIG_SETMASK, &omask, NULL);
errno = saved_errno;
_kse_critical_leave(crit);
return (ret);
}

View File

@ -39,30 +39,26 @@ __weak_reference(_execve, execve);
int
_execve(const char *name, char *const *argv, char *const *envp)
{
sigset_t omask;
struct kse_execve_args args;
struct pthread *curthread;
kse_critical_t crit;
int saved_errno;
int ret;
/*
* When exec'ing, set the kernel signal mask to the thread's
* signal mask to satisfy POSIX requirements. We have to enter
* a critical region so that the kernel thread doesn't get
* changed out from under us after setting the signal mask.
*/
curthread = _get_curthread();
crit = _kse_critical_enter();
__sys_sigprocmask(SIG_SETMASK, &curthread->sigmask, &omask);
ret = __sys_execve(name, argv, envp);
if (!_kse_isthreaded())
ret = __sys_execve(name, argv, envp);
else {
/*
* When exec'ing, set the kernel signal mask to the thread's
* signal mask to satisfy POSIX requirements.
*/
curthread = _get_curthread();
args.sigmask = curthread->sigmask;
args.sigpend = curthread->sigpend;
args.path = (char *)name;
args.argv = (char **)argv;
args.envp = (char **)envp;
args.reserved = NULL;
ret = kse_thr_interrupt(NULL, KSE_INTR_EXECVE, (long)&args);
}
/*
* If something went wrong, set the signal mask back but don't
* destroy errno.
*/
saved_errno = errno;
__sys_sigprocmask(SIG_SETMASK, &omask, NULL);
errno = saved_errno;
_kse_critical_leave(crit);
return (ret);
}