5
/* sanitize socketpair() error returns
7
/* #include <sane_socketpair.h>
9
/* int sane_socketpair(domain, type, protocol, result)
15
/* sane_socketpair() implements the socketpair(2) socket call, and
16
/* skips over silly error results such as EINTR.
18
/* Bizarre systems may have other harmless error results. Such
19
/* systems encourage programers to ignore error results, and
20
/* penalizes programmers who code defensively.
24
/* The Secure Mailer license must be distributed with this software.
27
/* IBM T.J. Watson Research
29
/* Yorktown Heights, NY 10598, USA
35
#include <sys/socket.h>
39
/* Utility library. */
42
#include "sane_socketpair.h"
44
/* sane_socketpair - sanitize socketpair() error returns */
46
int sane_socketpair(int domain, int type, int protocol, int *result)
48
static int socketpair_ok_errors[] = {
57
* Solaris socketpair() can fail with EINTR.
59
while ((ret = socketpair(domain, type, protocol, result)) < 0) {
60
for (count = 0; /* void */ ; count++) {
61
if ((err = socketpair_ok_errors[count]) == 0)
64
msg_warn("socketpair: %m (trying again)");