mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix truncating of files with <>;file combined with <#pattern
The issue with truncating files was caused by out-of-sync streams. Details and discussion: https://github.com/att/ast/issues/61 src/cmd/ksh93/sh/io.c: sh_iorestore(): - To be safe, sync all streams before restoring file descriptors. src/cmd/ksh93/tests/io.sh: - Add two regression tests for truncating files with this combination of redirections. - The second test, which invokes a -c script, is disabled for now as this triggers another corner case bug involving the SH_NOFORK optimisaton for -c scripts. That fix is for another commit. (cherry picked from commit 18fb64840365c2ff4608188e5487bd79d08f67d1)
This commit is contained in:
parent
a638e724d0
commit
e999f6b169
4 changed files with 32 additions and 1 deletions
|
@ -1749,6 +1749,11 @@ void sh_iorestore(Shell_t *shp, int last, int jmpval)
|
|||
register int origfd, savefd, fd;
|
||||
int flag = (last&IOSUBSHELL);
|
||||
last &= ~IOSUBSHELL;
|
||||
/*
|
||||
* There was an issue with truncating files (see 'ftruncate' below) that was caused by
|
||||
* out-of-sync streams. So, to be safe, sync all streams before restoring file descriptors.
|
||||
*/
|
||||
sfsync(NULL);
|
||||
for (fd = shp->topfd - 1; fd >= last; fd--)
|
||||
{
|
||||
if(!flag && filemap[fd].subshell)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue