From: Florian Weimer <fw@deneb.enyo.de>
Subject: Re: GNAT: Setting SIGPIPE to SIG_IGN
Date: Sun, 01 Sep 2002 12:16:16 +0200
Date: 2002-09-01T10:16:11+00:00 [thread overview]
Message-ID: <87lm6maubz.fsf@deneb.enyo.de> (raw)
In-Reply-To: 3D71318A.10909@cogeco.ca
"Warren W. Gay VE3WWG" <ve3wwg@cogeco.ca> writes:
> Florian Weimer wrote:
>> I want to instruct the GNAT run-time library that it sets the SIGPIPE
>> handler to SIG_IGN, so that system calls such as read() return EPIPE
>> instead of delivering a signal.
>
> Actually, I think you mean that read(2) returns EINTR (or EAGAIN
> on some platforms). EPIPE is returned when you write to a
> pipe without a reader.
It depends on the protocol. I believe that TCP implementation behaves
in the same way (as you describe it), but some other networking
protocol implementations deliver SIGPIPE even on recvmsg() etc.
>> This might sound like a silly question (I can write the necessary call
>> to signal(2) myself), but I don't want to work around the GNAT
>> run-time library. Any suggestions?
>
> I know what you're driving at. You'll need to know what GNAT is doing
> by default. I suspect that the SIG_DFL is the default for the SIGPIPE
> signal. SIG_DFL's meaning varies by signal on a particular host. But by
> default, for SIGPIPE, it defaults to delivering the signal usually.
The default for SIGPIPE is to terminate the thread, which is a bit too
drastic for my taste.
> You can approach this from two angles IMO:
>
> 1) Establish a signal handler in Ada, and ignore the signal (this will
> "catch the signal", and still cause EINTR to be returned for blocked
> system calls like read(2), when the handler returns).
It will cause EPIPE to be returned, so it works the way I want. (I
assumed that setting the handler to SIG_IGN had some magic side
effect, similar to other signals, but this is not the case.)
However, this pulls in the tasking run-time library which has got very
problematic side effects, at leat on GNU/Linux.
> 2) Deal with it in C terms, using SIG_IGN, which will have the same
> effect without having to specify a handler (the less code approach).
There is a problem with LinuxThreads (the threading implementation
provided by the GNU libc): signal handlers are thread-specific, so it
is not sufficient to set the handler in a single thread (GNAT
compensates for this, but you would have to do it on your own here).
next prev parent reply other threads:[~2002-09-01 10:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-31 9:36 GNAT: Setting SIGPIPE to SIG_IGN Florian Weimer
2002-08-31 21:13 ` Warren W. Gay VE3WWG
2002-09-01 0:20 ` Darren New
2002-09-01 10:16 ` Florian Weimer [this message]
2002-09-02 2:27 ` Warren W. Gay VE3WWG
2002-09-02 22:39 ` Florian Weimer
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox