summaryrefslogtreecommitdiff
path: root/Src/Modules/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Modules/socket.c')
-rw-r--r--Src/Modules/socket.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Src/Modules/socket.c b/Src/Modules/socket.c
index 469568a11..3f47636bc 100644
--- a/Src/Modules/socket.c
+++ b/Src/Modules/socket.c
@@ -120,13 +120,19 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
}
if (targetfd) {
- redup(sfd, targetfd);
- sfd = targetfd;
+ if (redup(sfd, targetfd) == -1)
+ sfd = -1;
+ else
+ sfd = targetfd;
}
else {
/* move the fd since no one will want to read from it */
sfd = movefd(sfd);
}
+ if (sfd == -1) {
+ zerrnam(nam, "cannot duplicate fd %d: %e", sfd, errno);
+ return 1;
+ }
setiparam("REPLY", sfd);