Skip to content
Tcl Source Code View Ticket
Login

View Ticket

exec ">>" does "a"-style opening, not "APPEND"

Closed / Fixed1245953fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2005-07-27 12:12:09
when I do:
  exec myprog >> logfile
this happens:

   open("logfile", O_WRONLY|O_CREAT|O_LARGEFILE, 0666) = 5
   _llseek(5, 0, [0], SEEK_END)            = 0

This is just a bad thing. Everyone used to shell-syntax 
expects the file to be opened with the "O_APPEND" flag,
such that two concurrent processes outputting to the
same file will not overwrite each others output, but always
append.
dkfplain2005-07-27 19:18:11
Logged In: YES 
user_id=79902

If O_APPEND is available (can we count on it?) we SHOULD use it.
dkfplain2005-07-27 19:24:32
Logged In: YES 
user_id=79902

O_APPEND looks universally available (or at least we already
use it without having configure check for it) so absolutely
no reason to not use it at all.
dkfplain2005-07-28 22:30:29
Logged In: YES 
user_id=79902

Fixed in HEAD and 8.4 branch; test is a little fragile on
very heavily loaded systems, but I don't know of any better
way to test it easily.

Note that Windows is not fixed, and cannot be fixed due to
fundamental lamenesses in the Win32 API (i.e. no equivalent
flag on file handles is available). Blame Microsoft.
Log in (anonymous is fine) to add a comment.