mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
New SIGPIPE behavior
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17903 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5c31ef0e4b
commit
39337dbf7d
9 changed files with 435 additions and 444 deletions
|
@ -58,7 +58,6 @@
|
|||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <signal.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/fcntl.h>
|
||||
|
@ -252,25 +251,6 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
|||
}
|
||||
}
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [GSFileHandle class])
|
||||
{
|
||||
#if !defined(__MINGW__)
|
||||
void (*handler)(int);
|
||||
/*
|
||||
* If SIGPIPE is not handled or ignored, we will abort on any attempt
|
||||
* to write to a pipe/socket that has been closed by the other end!
|
||||
*/
|
||||
handler = signal(SIGPIPE, SIG_IGN);
|
||||
if (handler != SIG_DFL)
|
||||
{
|
||||
signal(SIGPIPE, handler);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
+ (id) allocWithZone: (NSZone*)z
|
||||
{
|
||||
return NSAllocateObject ([self class], 0, z);
|
||||
|
|
|
@ -41,12 +41,6 @@
|
|||
#include "Foundation/NSDebug.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_SYS_SIGNAL_H
|
||||
#include <sys/signal.h>
|
||||
#endif
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h> /* for gethostname() */
|
||||
#endif
|
||||
|
@ -455,17 +449,6 @@ static Class runLoopClass;
|
|||
|
||||
wVersionRequested = MAKEWORD(2, 0);
|
||||
WSAStartup(wVersionRequested, &wsaData);
|
||||
#else
|
||||
void (*handler)(int);
|
||||
/*
|
||||
* If SIGPIPE is not handled or ignored, we will abort on any attempt
|
||||
* to write to a pipe/socket that has been closed by the other end!
|
||||
*/
|
||||
handler = signal(SIGPIPE, SIG_IGN);
|
||||
if (handler != SIG_DFL)
|
||||
{
|
||||
signal(SIGPIPE, handler);
|
||||
}
|
||||
#endif
|
||||
mutableArrayClass = [NSMutableArray class];
|
||||
mutableDataClass = [NSMutableData class];
|
||||
|
|
|
@ -40,12 +40,6 @@
|
|||
#include "Foundation/NSPathUtilities.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_SYS_SIGNAL_H
|
||||
#include <sys/signal.h>
|
||||
#endif
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h> /* for gethostname() */
|
||||
#endif
|
||||
|
@ -367,17 +361,6 @@ static Class runLoopClass;
|
|||
|
||||
wVersionRequested = MAKEWORD(2, 0);
|
||||
WSAStartup(wVersionRequested, &wsaData);
|
||||
#else
|
||||
void (*handler)(int);
|
||||
/*
|
||||
* If SIGPIPE is not handled or ignored, we will abort on any attempt
|
||||
* to write to a pipe/socket that has been closed by the other end!
|
||||
*/
|
||||
handler = signal(SIGPIPE, SIG_IGN);
|
||||
if (handler != SIG_DFL)
|
||||
{
|
||||
signal(SIGPIPE, handler);
|
||||
}
|
||||
#endif
|
||||
mutableArrayClass = [NSMutableArray class];
|
||||
mutableDataClass = [NSMutableData class];
|
||||
|
|
|
@ -49,6 +49,13 @@
|
|||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SIGNAL_H
|
||||
#include <sys/signal.h>
|
||||
#endif
|
||||
|
||||
#include "GSPrivate.h"
|
||||
|
||||
|
||||
|
@ -857,6 +864,43 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
|
|||
// See libgnustep-base-entry.m
|
||||
extern void gnustep_base_socket_init(void);
|
||||
gnustep_base_socket_init();
|
||||
#else
|
||||
|
||||
#ifdef SIGPIPE
|
||||
/*
|
||||
* If SIGPIPE is not handled or ignored, we will abort on any attempt
|
||||
* to write to a pipe/socket that has been closed by the other end!
|
||||
* We therefore need to ignore the signal if nothing else is already
|
||||
* handling it.
|
||||
*/
|
||||
#ifdef HAVE_SIGACTION
|
||||
{
|
||||
struct sigaction act;
|
||||
|
||||
if (sigaction(SIGPIPE, 0, &act) == 0 && act.sa_handler == SIG_DFL)
|
||||
{
|
||||
if (sigaction(SIGPIPE, &act, 0) != 0)
|
||||
{
|
||||
fprintf(stderr, "Unable to ignore SIGPIPE\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Unable to retrieve information about SIGPIPE\n");
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
void (*handler)(int);
|
||||
|
||||
handler = signal(SIGPIPE, SIG_IGN);
|
||||
if (handler != SIG_DFL)
|
||||
{
|
||||
signal(SIGPIPE, handler);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
|
@ -872,6 +916,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
GSSetLocaleC(LC_ALL, ""); // Set up locale from environment.
|
||||
#endif
|
||||
|
|
|
@ -41,12 +41,6 @@
|
|||
#include "Foundation/NSDebug.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_SYS_SIGNAL_H
|
||||
#include <sys/signal.h>
|
||||
#endif
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h> /* for gethostname() */
|
||||
#endif
|
||||
|
@ -419,17 +413,6 @@ static Class runLoopClass;
|
|||
|
||||
wVersionRequested = MAKEWORD(2, 0);
|
||||
WSAStartup(wVersionRequested, &wsaData);
|
||||
#else
|
||||
void (*handler)(int);
|
||||
/*
|
||||
* If SIGPIPE is not handled or ignored, we will abort on any attempt
|
||||
* to write to a pipe/socket that has been closed by the other end!
|
||||
*/
|
||||
handler = signal(SIGPIPE, SIG_IGN);
|
||||
if (handler != SIG_DFL)
|
||||
{
|
||||
signal(SIGPIPE, handler);
|
||||
}
|
||||
#endif
|
||||
mutableArrayClass = [NSMutableArray class];
|
||||
mutableDataClass = [NSMutableData class];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue