Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-03

How to handle SIGPIPE

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Tobias Giesen

Hello,

my app does http transfers using the Synapse library on Windows and Mac OS X. The transfers happen in separate threads. On Mac OS X only, the app is occasionally stopped due to a SIGPIPE.

How can I avoid or handle a SIGPIPE?

Cheers,
Tobias

Reply by email

Tobias Giesen
to Tobias Giesen

Hi,

I think the biggest issue is that MSG_NOSIGNAL is not defined on MAC OS, even though it was added a few years (?) ago. When I ported Synapse, unfortunately I defined it as 0. Now I changed that to $20000 and I'm hoping for the best ...

I also added this to my program, is that correct?

var NewSigRecSigActionRec;
    res:Integer;
initialization
  with NewSigRec do begin
    Integer(@Sa_Handler):=SIG_IGN; // ignore signal
    Sa_Mask[0]:=0;
    Sa_Flags:=0;
    end;
  res:=fpsigaction(SIGPIPE,@NewSigRec,@OldSigRec);

Cheers,
Tobias

Reply by email

Unknown author
to Tobias Giesen
Tobias Giesen wrote 8 lines
Hi, I think the biggest issue is that MSG_NOSIGNAL is not defined on MAC OS, even though it was added a few years (?) ago. When I ported Synapse, unfortunately I defined it as 0. Now I changed that to $20000 and I'm hoping for the best ... I also added this to my program, is that correct?

At first sight: yes.

Michael.

Show quoted text 21 lines
var NewSigRecSigActionRec; res:Integer; initialization with NewSigRec do begin Integer(@Sa_Handler):=SIG_IGN; // ignore signal Sa_Mask[0]:=0; Sa_Flags:=0; end; res:=fpsigaction(SIGPIPE,@NewSigRec,@OldSigRec); Cheers, Tobias _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Jonas Maebe
to Tobias Giesen: I think the biggest issue is that MSG_NOSIGNAL is not defined on MAC OS, even though it…
Tobias Giesen wrote 5 lines
I think the biggest issue is that MSG_NOSIGNAL is not defined on MAC OS, even though it was added a few years (?) ago. When I ported Synapse, unfortunately I defined it as 0. Now I changed that to $20000 and I'm hoping for the best ...

Hoping is not enough when changing random values. See http://bugs.freepascal.org/view.php?id=9401 for more info.

Jonas

Reply by email

Tobias Giesen
to Jonas Maebe
Hoping is not enough when changing random values. See http://bugs.freepascal.org/view.php?id=9401 for more info.

Wow. Many thanks!

I read that MSG_NOSIGNAL is now supported by MacOS, too, but I don't really know.

So now I am calling fpsetsockopt with SO_NOSIGPIPE as the first thing after every fpSocket call. That should probably do it, right?

The bug comments on the above URL are not totally clear because you cannot actually pass any options to the Connect call. So I assume you should use fpsetsockopt before the Connect call.

Cheers,
Tobias

Reply by email