Bug 14422 – std.process: Pipes do not append to files on Win64

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2015-04-07T11:50:00Z
Last change time
2017-07-19T17:43:01Z
Keywords
pull
Assigned to
nobody
Creator
dlang-bugzilla

Comments

Comment #0 by dlang-bugzilla — 2015-04-07T11:50:37Z
//////////////////////////// test.d /////////////////////////// import std.process; import std.stdio; import std.file; void main() { auto fn = "fn.txt"; std.file.write(fn, "AAAAAAAAAA"); auto f = File(fn, "a"); spawnProcess(["cmd", "/c", "echo BBBBB"], stdin, f).wait(); auto data = readText(fn); assert(data == "AAAAAAAAAABBBBB\r\n", data); } /////////////////////////////////////////////////////////////// This program runs fine on Win32, but the assert fails on Win64. For some reason, the "a" mode is being ignored, and the content is written to the beginning of the file, clobbering the original file header.
Comment #1 by dlang-bugzilla — 2015-04-07T12:15:57Z
C program which reproduces this bug: /////////////////////// ctest.c /////////////////////// #include <stdio.h> #include <windows.h> void main() { FILE *f; PROCESS_INFORMATION pi = {0}; STARTUPINFO si = {sizeof(STARTUPINFO)}; f = fopen("test.txt", "w"); fprintf(f, "AAAAAAAAAA\n"); fclose(f); f = fopen("test.txt", "a"); si.hStdOutput = (HANDLE)_get_osfhandle(_fileno(f)); si.dwFlags = STARTF_USESTDHANDLES; CreateProcess(NULL, "cmd /c \"echo BBBBB\"", NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi); } ///////////////////////////////////////////////////////
Comment #2 by dlang-bugzilla — 2015-04-07T12:29:06Z
Comment #3 by github-bugzilla — 2015-04-09T14:28:21Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/b28eb9fab8d27a7134daabf33544198bb4fbd02b fix Issue 14422 - std.process: Pipes do not append to files on Win64 https://github.com/D-Programming-Language/phobos/commit/eecc989b2c7901d1dce40c761329920b690da0c0 Merge pull request #3160 from CyberShadow/pull-20150407-122150 fix Issue 14422 - std.process: Pipes do not append to files on Win64
Comment #4 by github-bugzilla — 2017-07-19T17:43:01Z
Commits pushed to dmd-cxx at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/b28eb9fab8d27a7134daabf33544198bb4fbd02b fix Issue 14422 - std.process: Pipes do not append to files on Win64 https://github.com/dlang/phobos/commit/eecc989b2c7901d1dce40c761329920b690da0c0 Merge pull request #3160 from CyberShadow/pull-20150407-122150