-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFPtXfEf9E0noFvlzgRAp1oAKDfNQlGGNoDVqldWfqrBSoB80yRAQCeOXaf
1c3pIE6Eni77f28IGL7AQv4=
=sEh9
-----END PGP SIGNATURE-----
On 17/05/12 17:59, clerew5 wrote:
[...]
> sigemptyset(&set);
> sigaddset(&set, SIGUSR1);
> sigaddset(&set, SIGUSR2);
> sigaddset(&set, SIGTERM);
> sigaddset(&set, SIGINT);
> sigaddset(&set, SIGSEGV);
> sigaddset(&set, SIGBUS);
> sigaddset(&set, SIGILL);
> sigaddset(&set, SIGFPE);
> sigaddset(&set, SIGSYS);
> and I have created a pthread which contains
> sigwait(&set, &signal);
I'm not quite sure what you're trying to do here --- AIUI sigwait()
blocks until a signal *for the blocked thread* is received, so no code
that can generate the signal will be run... (unless you send it manually
from another thread).
If you're trying to catch a signal thrown by code in a different thread,
then I don't think that will work.
The simplest approach is to just register a SIGSEGV signal handler in
the thread that's going to be doing the work. Then, when the signal is
thrown, your handler will run. If you want to do the work in a different
thread, then you'll need some sort of IPC between threads (but beware
that you can only run a small subset of functions safely from inside a
signal handler).
A more complicated and slower but much more flexible approach is to use
ptrace to monitor the running thread; when a signal is thrown, it will
be suspended and your monitor will be sent a message. It all depends
what you want to do.
(Also, check out libsigsegv: http://libsigsegv.sourceforge.net)
--
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│
│ "Never attribute to malice what can be adequately explained by
│ stupidity." --- Nick Diamos (Hanlon's Razor)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment