getouraddr()
{
char buff[256];
- struct hostent *he;
-
- if (gethostname(buff,256) < 0)
- return;
-
- if ((he = gethostbyname(buff)) == NULL)
- return;
-
- our_addr = *(struct in_addr *)he->h_addr;
+ struct hostent *he = NULL;
+
+ if (gethostname(buff,256) == 0)
+ he = gethostbyname(buff);
+ if (he)
+ our_addr = *(struct in_addr *)he->h_addr;
+ if (our_addr.s_addr == 0)
+ our_addr.s_addr = loopback_addr.s_addr;
}
#if SIZEOF_CHAR_P == 8
/* don't want to clobber the original */
char *bptr;
char *curarg;
- int c, i;
+ int c, i, ret;
DEBUG_CALL("fork_exec");
DEBUG_ARG("so = %lx", (long)so);
*/
s = socket(AF_INET, SOCK_STREAM, 0);
addr.sin_addr = loopback_addr;
- connect(s, (struct sockaddr *)&addr, addrlen);
+ do {
+ ret = connect(s, (struct sockaddr *)&addr, addrlen);
+ } while (ret < 0 && errno == EINTR);
}
#if 0
* The only reason this will block forever is if socket()
* of connect() fail in the child process
*/
- so->s = accept(s, (struct sockaddr *)&addr, &addrlen);
- closesocket(s);
+ do {
+ so->s = accept(s, (struct sockaddr *)&addr, &addrlen);
+ } while (so->s < 0 && errno == EINTR);
+ closesocket(s);
opt = 1;
setsockopt(so->s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int));
opt = 1;