about summary refs log tree commit diff
path: root/Src/Modules/socket.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2009-09-22 16:04:13 +0000
committerWayne Davison <wayned@users.sourceforge.net>2009-09-22 16:04:13 +0000
commit2f8aaaf5e425f2285e028e35a52d0766067ab3fd (patch)
tree02b3a23ed9f9b5d6bc0521ac44e6a9fc7524e14e /Src/Modules/socket.c
parent51409732d0e647661915fde0b15323005be7c9e8 (diff)
downloadzsh-2f8aaaf5e425f2285e028e35a52d0766067ab3fd.tar.gz
zsh-2f8aaaf5e425f2285e028e35a52d0766067ab3fd.tar.xz
zsh-2f8aaaf5e425f2285e028e35a52d0766067ab3fd.zip
27286: Made movefd() return the targetfd on success. Added
a little more error checking in the callers of movefd().
Diffstat (limited to 'Src/Modules/socket.c')
-rw-r--r--Src/Modules/socket.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/Src/Modules/socket.c b/Src/Modules/socket.c
index 3f47636bc..ad7eb5884 100644
--- a/Src/Modules/socket.c
+++ b/Src/Modules/socket.c
@@ -120,10 +120,7 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
 	}
 
 	if (targetfd) {
-	    if (redup(sfd, targetfd) == -1)
-		sfd = -1;
-	    else
-		sfd = targetfd;
+	    sfd = redup(sfd, targetfd);
 	}
 	else {
 	    /* move the fd since no one will want to read from it */
@@ -205,8 +202,11 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
 	}
 
 	if (targetfd) {
-	    redup(rfd, targetfd);
-	    sfd = targetfd;
+	    sfd = redup(rfd, targetfd);
+	    if (sfd < 0) {
+		zerrnam(nam, "could not duplicate socket fd to %d: %e", targetfd, errno);
+		return 1;
+	    }
 	}
 	else {
 	    sfd = rfd;
@@ -242,8 +242,11 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
 	else
 	{
 	    if (targetfd) {
-		redup(sfd, targetfd);
-		sfd = targetfd;
+		sfd = redup(sfd, targetfd);
+		if (sfd < 0) {
+		    zerrnam(nam, "could not duplicate socket fd to %d: %e", targetfd, errno);
+		    return 1;
+		}
 	    }
 
 	    setiparam("REPLY", sfd);