Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2005-07-28
22:30 • Closed ticket [1245953fff]: exec ">>" does "a"-style o... artifact: 6df5db7869 user: dkf
2005-07-27
19:24 • Ticket [1245953fff]: 4 changes artifact: 04d462d92a user: dkf
19:18 • Ticket [1245953fff]: 5 changes artifact: fb9b38f438 user: dkf
12:12 • New ticket [1245953fff]. artifact: b45f623772 user: avl42

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.