mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-06-09 18:38:05 +02:00
52509: manage internals of stdio objects when performing redirections.
This commit is contained in:
parent
85545af42b
commit
d7cf4f25eb
3 changed files with 28 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2024-01-28 Bart Schaefer <schaefer@zsh.org>
|
||||||
|
|
||||||
|
* 52509: configure.ac, Src/utils.c: manage internals of stdio
|
||||||
|
objects when performing redirections.
|
||||||
|
|
||||||
2024-01-28 Oliver Kiddle <opk@zsh.org>
|
2024-01-28 Oliver Kiddle <opk@zsh.org>
|
||||||
|
|
||||||
* 52500: Src/Zle/zle.h, Src/Zle/zle_refresh.c, Src/prompt.c:
|
* 52500: Src/Zle/zle.h, Src/Zle/zle_refresh.c, Src/prompt.c:
|
||||||
|
|
22
Src/utils.c
22
Src/utils.c
|
@ -2008,6 +2008,28 @@ redup(int x, int y)
|
||||||
{
|
{
|
||||||
int ret = y;
|
int ret = y;
|
||||||
|
|
||||||
|
#ifdef HAVE_FPURGE
|
||||||
|
/* Make sure buffers are cleared when changing descriptor for a
|
||||||
|
* FILE object. No fflush() here because the only way anything
|
||||||
|
* can legitimately be left in the buffer is when an error has
|
||||||
|
* occurred, so attempting flush here would at best error again
|
||||||
|
* and at worst squirt out something unexpected.
|
||||||
|
*/
|
||||||
|
if (stdout && y == fileno(stdout))
|
||||||
|
fpurge(stdout);
|
||||||
|
if (stderr && y == fileno(stderr))
|
||||||
|
fpurge(stderr);
|
||||||
|
if (shout && y == fileno(shout))
|
||||||
|
fpurge(shout);
|
||||||
|
if (xtrerr && y == fileno(xtrerr))
|
||||||
|
fpurge(xtrerr);
|
||||||
|
#ifndef _IONBF
|
||||||
|
/* See init.c setupshin() -- stdin otherwise unbuffered */
|
||||||
|
if (stdin && y == fileno(stdin))
|
||||||
|
fpurge(stdin);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
if(x < 0)
|
if(x < 0)
|
||||||
zclose(y);
|
zclose(y);
|
||||||
else if (x != y) {
|
else if (x != y) {
|
||||||
|
|
|
@ -1295,7 +1295,7 @@ AC_CHECK_FUNCS(strftime strptime mktime timelocal \
|
||||||
select poll \
|
select poll \
|
||||||
readlink faccessx fchdir ftruncate \
|
readlink faccessx fchdir ftruncate \
|
||||||
fstat lstat lchown fchown fchmod \
|
fstat lstat lchown fchown fchmod \
|
||||||
fseeko ftello \
|
fpurge fseeko ftello \
|
||||||
mkfifo _mktemp mkstemp \
|
mkfifo _mktemp mkstemp \
|
||||||
waitpid wait3 \
|
waitpid wait3 \
|
||||||
sigaction sigblock sighold sigrelse sigsetmask sigprocmask \
|
sigaction sigblock sighold sigrelse sigsetmask sigprocmask \
|
||||||
|
|
Loading…
Reference in a new issue