summary refs log tree commit diff
path: root/Src/Modules/socket.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2009-09-22 09:17:05 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2009-09-22 09:17:05 +0000
commit51409732d0e647661915fde0b15323005be7c9e8 (patch)
treedee1a7c103a59916c77fe7fac4aa8f9f2171a8ef /Src/Modules/socket.c
parent997eafdcad85e9a2c59db1141b404dd4c4bcb22d (diff)
downloadzsh-51409732d0e647661915fde0b15323005be7c9e8.tar.gz
zsh-51409732d0e647661915fde0b15323005be7c9e8.tar.xz
zsh-51409732d0e647661915fde0b15323005be7c9e8.zip
27284: better use of movefd()
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);