mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-27 16:50:58 +01:00
27284: better use of movefd()
This commit is contained in:
parent
997eafdcad
commit
51409732d0
7 changed files with 66 additions and 18 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue