diff options
| author | Peter Stephenson <pws@zsh.org> | 2017-09-29 16:29:49 +0100 |
|---|---|---|
| committer | Peter Stephenson <pws@zsh.org> | 2017-09-29 16:29:49 +0100 |
| commit | a1276c88e1137c643bb8055d719afc17cb37bf0f (patch) | |
| tree | 6269aeef2fc25b601652147a41b1904369f6a624 | |
| parent | 41773: Array index assignment tests for KSH_ARRAYS (diff) | |
| download | zsh-a1276c88e1137c643bb8055d719afc17cb37bf0f.tar zsh-a1276c88e1137c643bb8055d719afc17cb37bf0f.tar.gz zsh-a1276c88e1137c643bb8055d719afc17cb37bf0f.tar.bz2 zsh-a1276c88e1137c643bb8055d719afc17cb37bf0f.tar.lz zsh-a1276c88e1137c643bb8055d719afc17cb37bf0f.tar.xz zsh-a1276c88e1137c643bb8055d719afc17cb37bf0f.tar.zst zsh-a1276c88e1137c643bb8055d719afc17cb37bf0f.zip | |
41789: Don't save fd if -1.
We try to move an fd which isn't opend but it will feel.
This needs handling specially in the new code for marking
saved fd's.
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | Src/exec.c | 19 |
2 files changed, 16 insertions, 8 deletions
@@ -1,3 +1,8 @@ +2017-09-29 Peter Stephenson <p.stephenson@samsung.com> + + * 41789: Src/exec.c: Don't try to mark an FD as saved if it + couldn't be moved. + 2017-09-28 Oliver Kiddle <opk@zsh.org> * 41772: Src/Zle/computil.c, Test/Y03arguments.ztst: fix bug diff --git a/Src/exec.c b/Src/exec.c index 0d2dc4ebb..780998b1a 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -2325,16 +2325,19 @@ addfd(int forked, int *save, struct multio **mfds, int fd1, int fd2, int rflag, * fd1 may already be closed here, so * ignore bad file descriptor error */ - if (fdN < 0 && errno != EBADF) { - zerr("cannot duplicate fd %d: %e", fd1, errno); - mfds[fd1] = NULL; - closemnodes(mfds); - return; + if (fdN < 0) { + if (errno != EBADF) { + zerr("cannot duplicate fd %d: %e", fd1, errno); + mfds[fd1] = NULL; + closemnodes(mfds); + return; + } + } else { + DPUTS(fdtable[fdN] != FDT_INTERNAL, + "Saved file descriptor not marked as internal"); + fdtable[fdN] |= FDT_SAVED_MASK; } save[fd1] = fdN; - DPUTS(fdtable[fdN] != FDT_INTERNAL, - "Saved file descriptor not marked as internal"); - fdtable[fdN] |= FDT_SAVED_MASK; } } } |
