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
) __attribute__((unused
));
18 static int safe_sem_post( sem_t
*sem
) {
20 struct sigaction oldsa
;
24 sa
.sa_sigaction
= abrt_handler
;
25 sigemptyset( &sa
.sa_mask
);
26 sa
.sa_flags
= SA_SIGINFO
;
28 sigaction( SIGABRT
, &sa
, &oldsa
);
30 if ( ( e
= sigsetjmp( env
, 1 ) ) == 0 ) {
37 sigaction( SIGABRT
, &oldsa
, NULL
);
42 #define sem_post safe_sem_post