mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 08:41:03 +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
0cd5b3a710
commit
d113f2549c
9 changed files with 435 additions and 444 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue