home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.programmer:4459 comp.unix.xenix.sco:2748
- Path: sparky!uunet!munnari.oz.au!bunyip.cc.uq.oz.au!kirk!lance!ptcburp!michi
- From: michi@ptcburp.ptcbu.oz.au (Michael Henning)
- Newsgroups: comp.unix.programmer,comp.unix.xenix.sco
- Subject: Re: Calling longjmp() from signal handler: portable?
- Message-ID: <1992Aug27.001005.22826@ptcburp.ptcbu.oz.au>
- Date: 27 Aug 92 00:10:05 GMT
- References: <2A9BCC57.640F@tct.com>
- Organization: Pyramid Technology Corporation
- Lines: 39
-
- chip@tct.com (Chip Salzenberg) writes:
-
- >In working on Smail 3, I've found that I need to interrupt a blocking
- >system call (a kernel locking primitive, to be precise). Ron Karr
- >seems to think that calling longjmp() from a signal handler will work
- >with all known versions of UNIX, not just with BSD as I assumed.
-
- >Is Ron right that longjmp() always works from signal handlers? Or am
- >I correct that, for example, SCO Xenix sets up a separate stack frame
- >for signal handlers, so longjmp() won't work correctly?
-
- From the setcontext(3C) man page on our V.4 system (Pyramid DC/OSx):
-
- When a signal handler is executed, the current user context is saved
- and a new context is created by the kernel. If the process leaves the
- signal handler via longjmp(3C) the original context will not be
- restored, and future calls to getcontext will not be reliable. Signal
- handlers should use siglongjmp(3C) or setcontext instead.
-
-
- The man page for sigsetjmp(3C) says:
-
- sigsetjmp saves the calling process's registers and stack environment
- [see sigaltstack(2)] in env (whose type, sigjmp_buf, is defined in the
- <setjmp.h> header file) for later use by siglongjmp. If savemask is
- non-zero, the calling process's signal mask [see sigprocmask(2)] and
- scheduling parameters [see priocntl(2)] are also saved. sigsetjmp
- returns the value 0.
-
-
- So, the answer is that if you haven't done anything strange with setcontext
- or sigaltstack, setjmp/longjmp should be OK, otherwise use sigsetjmp/siglongjmp.
-
- Michi.
- --
- -m------- Michael Henning +61 75 950255
- ---mmm----- Pyramid Technology +61 75 722475 FAX
- -----mmmmm--- Research Park, Bond University michi@ptcburp.ptcbu.oz.au
- -------mmmmmmm- Gold Coast, Q 4229, AUSTRALIA uunet!munnari!ptcburp.oz!michi
-