From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,400599f96e15af9b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-08-31 14:13:47 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!news.stealth.net!news.stealth.net!feed.cgocable.net!read2.cgocable.net.POSTED!53ab2750!not-for-mail Message-ID: <3D71318A.10909@cogeco.ca> From: "Warren W. Gay VE3WWG" User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0rc2) Gecko/20020618 Netscape/7.0b1 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: GNAT: Setting SIGPIPE to SIG_IGN References: <87ofbj5q0r.fsf@deneb.enyo.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 31 Aug 2002 17:13:46 -0400 NNTP-Posting-Host: 24.150.168.167 X-Complaints-To: abuse@cogeco.ca X-Trace: read2.cgocable.net 1030828489 24.150.168.167 (Sat, 31 Aug 2002 17:14:49 EDT) NNTP-Posting-Date: Sat, 31 Aug 2002 17:14:49 EDT Organization: Cogeco Cable Xref: archiver1.google.com comp.lang.ada:28635 Date: 2002-08-31T17:13:46-04:00 List-Id: 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. > 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. 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). 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). > The RM interfaces do not appear > to be helpful here because I think that if no handler is attached, the > default handler is invoked, which is not what I want. Actually, I believe there is no handler at all (the process just aborts, based upon a O/S "system" action specified by SIG_DFL for SIGPIPE). I believe GNAT leaves the setting as SIG_DFL. You can check this by calling a C program that retrieves the current setting and comparing it against SIG_DFL. If this is the case, then GNAT is doing nothing with the signal (not handling it), but the O/S is permitted to raise the signal (the default system action occurs). I havn't yet fully dug into this, but I do believe there was a signal names related change after GNAT 3.13p, since my signal code would not compile on gcc-3.1.1 when I tried it (I think the signal name definitions moved to a child package.) So approach # 2 might be "more portable", but I am just guessing with a poor memory ;-) -- Warren W. Gay VE3WWG http://home.cogeco.ca/~ve3wwg