[Libwebsockets] Signal Trap eclisping my Trap handler

Shmuel Weiss sweiss at kramerel.com
Wed Nov 16 14:47:17 CET 2016

And why not doing this in libwebsockets?


Add SIGPIPE to the signal mask using pthread_sigmask

Signals can be temporarily blocked by adding them to the signal mask using the function pthread_sigmask:

sigset_t sigpipe_mask;
sigaddset(&sigpipe_mask, SIGPIPE);
sigset_t saved_mask;
if (pthread_sigmask(SIG_BLOCK, &sigpipe_mask, &saved_mask) == -1) {

Each thread has its own signal mask, so it is safe to do this within a library provided that you restore the mask afterwards. Blocking only defers delivery of the signal, so it remains pending, but for current purposes that will suffice.

-----Original Message-----
From: Andy Green [mailto:andy at warmcat.com] 
Sent: Wednesday, November 16, 2016 15:46
To: Shmuel Weiss; libwebsockets at ml.libwebsockets.org
Subject: Re: [Libwebsockets] Signal Trap eclisping my Trap handler

On November 16, 2016 9:42:19 PM GMT+08:00, Shmuel Weiss <sweiss at kramerel.com> wrote:
>Hi Andy,
>We have a trap Handler in our main.cpp which seems to be eclipsed by 
>the sigtrap of the Libwebsocket,
>How can we prevent libwebsocket to sigtrap ?

Just reassert your desired user signal handling after lws has created his context.


>Shmuel Weiss
>Kramer Electronics
>Project Lead and Software Team Leader
>Email: sweiss at kramerel.com<mailto:sweiss at kramerel.com>    Web:
>www.kramerelectronics.com<http://www.kramerelectronics.com/>    Tel:
>Cell: +972-54-3344141    Fax: +972-2-6535369    Address: 3 Am VeOlamo,
>Jerusalem, 9546303, Israel
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org

More information about the Libwebsockets mailing list