Actions
Bug #12467
closedOpen mode 'a' does not work for Process.spawn on Windows
Status:
Third Party's Issue
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32]
Description
Example:
spawn 'ruby -e "p Time.now"', [:out, :err] => ['log.txt', 'a']
sleep 1
spawn 'ruby -e "p Time.now"', [:out, :err] => ['log.txt', 'a']
sleep 1
p File.read('log.txt')
This program looks work correctly at first.
c:\>ruby spawn_bug.rb
"2016-06-07 18:47:25 +0900\n2016-06-07 18:28:17 +0900\n"
However, when I run it again, the log file is truncated like 'w' flag.
c:\>ruby spawn_bug.rb
"2016-06-07 18:47:38 +0900\n2016-06-07 18:28:17 +0900\n"
This is the same if I open the log file manually with File.open.
f = File.open('log.txt', 'a')
spawn 'ruby -e "p Time.now"', [:out, :err] => f
sleep 1
spawn 'ruby -e "p Time.now"', [:out, :err] => f
sleep 1
p File.read('log.txt')
I tried this on Windows 10. (Also confirmed this does not happen on Mac OS X 10.11 + ruby 2.2)
Actions
Like0
Like0