Subject: Re: getting rid of sigcontext and adding siginfo support to libpthread
To: Christos Zoulas <christos@zoulas.com>
From: Nathan J. Williams <nathanw@wasabisystems.com>
List: tech-kern
Date: 09/11/2003 18:37:15
christos@zoulas.com (Christos Zoulas) writes:
> +static void
> +pthread__make_siginfo(siginfo_t *si, int sig)
> +{
> + (void)memset(&si, 0, sizeof(si));
> + si->si_signo = sig;
> + si->si_code = SI_USER;
> + si->si_uid = getuid();
> + si->si_pid = getpid();
> +}
I'd be sort of tempted to cache the pid and maybe the uid to avoid two
system calls for every in-program signal, but I guess setuid could
make that a pain. Anyway, something to ponder in the future.
> - /*
> - * XXX we don't support siginfo here yet.
> - */
> - PTHREAD_UCONTEXT_TO_SIGCONTEXT(oldmask, uc, &psc);
> - handler(sig, code, &psc.psc_context);
> - PTHREAD_SIGCONTEXT_TO_UCONTEXT(&psc, uc);
> +#ifdef __HAVE_SIGINFO
> + (*handler)(info->si_signo, info, uc);
> +#else
> + {
> + struct pthread__sigcontext psc;
> +
> + /*
> + * XXX we don't support siginfo here yet.
> + */
> + PTHREAD_UCONTEXT_TO_SIGCONTEXT(uc->uc_stack.ss_sp, uc, &psc);
> + (*((void *)(*)(int, int, struct sigcontext *)handler))
> + (si->si_signo, si->si_trap, &psc.psc_context);
> + PTHREAD_SIGCONTEXT_TO_UCONTEXT(&psc, uc);
> + }
> +#endif
The use of uc->uc_stack.ss_sp there is.... sneaky, and probably
deserves a comment.
- Nathan