don't lose more file descriptors
SCCS-vsn: lib/libc/net/rcmd.c 5.6
-static char sccsid[] = "@(#)rcmd.c 5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)rcmd.c 5.6 (Berkeley) %G%";
#endif not lint
#include <stdio.h>
#endif not lint
#include <stdio.h>
*ahost = hp->h_name;
retry:
s = rresvport(&lport);
*ahost = hp->h_name;
retry:
s = rresvport(&lport);
+ if (s < 0) {
+ if (errno == EAGAIN)
+ fprintf(stderr, "socket: All ports in use\n");
+ else
+ perror("rcmd: socket");
sin.sin_family = hp->h_addrtype;
bcopy(hp->h_addr, (caddr_t)&sin.sin_addr, hp->h_length);
sin.sin_port = rport;
sin.sin_family = hp->h_addrtype;
bcopy(hp->h_addr, (caddr_t)&sin.sin_addr, hp->h_length);
sin.sin_port = rport;
sin.sin_port = htons((u_short)*alport);
if (bind(s, (caddr_t)&sin, sizeof (sin), 0) >= 0)
return (s);
sin.sin_port = htons((u_short)*alport);
if (bind(s, (caddr_t)&sin, sizeof (sin), 0) >= 0)
return (s);
- if (errno == EADDRNOTAVAIL)
- return (-1);
if (errno != EADDRINUSE) {
if (errno != EADDRINUSE) {
(void) close(s);
return (-1);
}
(*alport)--;
if (*alport == IPPORT_RESERVED/2) {
(void) close(s);
return (-1);
}
(*alport)--;
if (*alport == IPPORT_RESERVED/2) {
- fprintf(stderr, "socket: All ports in use\n");
+ errno = EAGAIN; /* close */