diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2009-09-22 09:17:05 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2009-09-22 09:17:05 +0000 |
commit | 51409732d0e647661915fde0b15323005be7c9e8 (patch) | |
tree | dee1a7c103a59916c77fe7fac4aa8f9f2171a8ef /Src/Modules/tcp.c | |
parent | 997eafdcad85e9a2c59db1141b404dd4c4bcb22d (diff) | |
download | zsh-51409732d0e647661915fde0b15323005be7c9e8.tar.gz zsh-51409732d0e647661915fde0b15323005be7c9e8.tar.xz zsh-51409732d0e647661915fde0b15323005be7c9e8.zip |
27284: better use of movefd()
Diffstat (limited to 'Src/Modules/tcp.c')
-rw-r--r-- | Src/Modules/tcp.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Src/Modules/tcp.c b/Src/Modules/tcp.c index 2b9e9df18..2825cb978 100644 --- a/Src/Modules/tcp.c +++ b/Src/Modules/tcp.c @@ -446,14 +446,22 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func)) } if (targetfd) { - redup(sess->fd,targetfd); - sess->fd = targetfd; + if (redup(sess->fd,targetfd) == -1) + sess->fd = -1; + else + sess->fd = targetfd; } else { /* move the fd since no one will want to read from it */ sess->fd = movefd(sess->fd); } + if (sess->fd == -1) { + zwarnnam(nam, "cannot duplicate fd %d: %e", sess->fd, errno); + tcp_close(sess); + return 1; + } + setiparam("REPLY", sess->fd); if (verbose) |