FVWM: POSIX signals and siglongjmp

From: Chris Rankin <rankinc_at_bellsouth.net>
Date: Fri, 18 Dec 1998 09:09:41 -0500 (EST)

> I'm curious about the portability of using longjmp to get out of a signal
> handler, though--don't some platforms use a seperate stack for signal
> handlers?

I am under the impression that "siglongjmp" is a variant *explicitly*
designed to be called from within a signal handler. Such
implementation details as switching stacks should be handled
internally by the system. Therefore if it has "siglongjmp", it should
work. Plain "longjmp" has no such guarantee.

> And do all current BSD systems possess sigaction?

That's a good question. I had assumed that POSIX 1 was prevalent in
the modern UNIX world. I have programmed on Linux, HPUX, Solaris and
AIX and all these platforms have provided POSIX 1.

There is an alternative *but less robust* way of improving the signal
handling that involves having a "static volatile sig_atomic_t
isDeadPipe" variable, which is set to "True" within the signal
handler. This approach wouldn't need to block other signals since
multiple handlers could set the variable to True as often as they
wished. The point of the variable would be to control the event loop
so that "while (1) { ... }" would become "while ( !isDeadPipe )
{ ... }". The problem with this approach is that it's less responsive
unless you preface every call which could block with "if
(!isDeadPipe)":

Consider: a signal arrives just AFTER checking isDeadPipe in the main
event loop but BEFORE the call to My_XNextEvent(). Or possibly a signal
arrives in My_XNextEvent() before the call to select(). The isDeadPipe
variable suddenly becomes True, but the process blocks anyway and
needs another signal or something to free it. This is why I took the
siglongjmp approach - it FORCES the termination issue.

If anyone has a system that does NOT have POSIX 1 support (bear in
mind that POSIX 1 support may not appear until you #define
_POSIX_SOURCE) can they speak now, please?

Chris.
--
Visit the official FVWM web page at <URL: http://fvwm.math.uh.edu/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_hpc.uh.edu.
To report problems, send mail to fvwm-owner_at_hpc.uh.edu.
Received on Sat Dec 19 1998 - 02:46:30 GMT

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:38:02 BST