[Issue 1491] New: if working with timed-out socket, SIGPIPE will kill program
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 10 18:16:58 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1491
Summary: if working with timed-out socket, SIGPIPE will kill
program
Product: D
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Keywords: patch
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: bugzilla at digitalmars.com
ReportedBy: default_357-line at yahoo.de
On linux, when trying to work with a socket that has already expired, the
signal SIGPIPE is raised.
If unchecked, it will terminate the program.
Since there is a defined behavior for trying to work with timed-out sockets
(send/receive return -1), we can safely ignore this signal.
The following patch for gdc's std/thread.d (should be equally applicable to
dmd) implements this:
diff socket.d.old socket.d -u
--- socket.d.old 2007-09-11 03:05:54.000000000 +0200
+++ socket.d 2007-09-11 03:10:30.000000000 +0200
@@ -126,6 +126,17 @@
}
}
+version (Win32) { }
+else
+{
+ extern(C)
+ {
+ typedef void function(int) sighandler_t;
+ sighandler_t signal(int signum, sighandler_t handler);
+ const int SIGPIPE=13;
+ const sighandler_t SIG_IGN=cast(sighandler_t)cast(void*)1;
+ }
+}
static this()
{
@@ -140,6 +151,10 @@
if(val) // Request Winsock 2.2 for IPv6.
throw new SocketException("Unable to initialize socket
library", val);
}
+ else
+ {
+ signal(SIGPIPE, SIG_IGN);
+ }
}
--
More information about the Digitalmars-d-bugs
mailing list