10 * Newer glibc crashes on really bogus semaphors.
11 * Catch a SIGABRT and turn it into a EINVAL.
13 static void abrt_handler( int signum
, siginfo_t
*siginfo
, void *sigcontext
) {
14 siglongjmp( env
, EINVAL
);
17 static int safe_sem_post( sem_t
*sem
) {
19 struct sigaction oldsa
;
23 sa
.sa_sigaction
= abrt_handler
;
24 sigemptyset( &sa
.sa_mask
);
25 sa
.sa_flags
= SA_SIGINFO
;
27 sigaction( SIGABRT
, &sa
, &oldsa
);
29 if ( ( e
= sigsetjmp( env
, 1 ) ) == 0 ) {
36 sigaction( SIGABRT
, &oldsa
, NULL
);
41 #define sem_post safe_sem_post