[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#12366: [gnu-prog-discuss] Writing unwritable files
From: |
Paul Eggert |
Subject: |
bug#12366: [gnu-prog-discuss] Writing unwritable files |
Date: |
Thu, 06 Sep 2012 11:23:21 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 |
On 09/06/2012 10:35 AM, Bernhard Voelker wrote:
> Why can't 'sed -i' be made atomic for the user?
> Today, it creates a temporary file for the output.
> At the end, it calls rename(). What if it instead
> rewinds the input and that temporary file and copies
> it's content to the input file?
That's kind of what 'sort -o' does, and it also
has race conditions. For example, in that last phase
while it's copying the content to the input file, some other
process might be reading the input file.
There is no good general and portable atomic solution to
this sort of problem, not in POSIX anyway. Practical
implementations of utilities like 'sed' and 'sort'
and 'shuf' all involve races of some sort or another.
- bug#12366: [gnu-prog-discuss] Writing unwritable files, (continued)
- bug#12366: [gnu-prog-discuss] Writing unwritable files, Bernhard Voelker, 2012/09/06
- bug#12366: [gnu-prog-discuss] Writing unwritable files, Jim Meyering, 2012/09/06
- bug#12366: [gnu-prog-discuss] Writing unwritable files, Paul Eggert, 2012/09/06
- bug#12366: [gnu-prog-discuss] Writing unwritable files, Paolo Bonzini, 2012/09/06
- bug#12366: [gnu-prog-discuss] Writing unwritable files, Paul Eggert, 2012/09/06
- bug#12366: [gnu-prog-discuss] Writing unwritable files, Paolo Bonzini, 2012/09/06
- bug#12366: [gnu-prog-discuss] Writing unwritable files, Paul Eggert, 2012/09/06
- bug#12366: [gnu-prog-discuss] Writing unwritable files, Bob Proulx, 2012/09/06
- bug#12366: [gnu-prog-discuss] Writing unwritable files, Paul Eggert, 2012/09/06
- bug#12366: [gnu-prog-discuss] Writing unwritable files, Bernhard Voelker, 2012/09/06
- bug#12366: [gnu-prog-discuss] Writing unwritable files,
Paul Eggert <=
- bug#12366: [gnu-prog-discuss] bug#12366: Writing unwritable files, John Darrington, 2012/09/06
- bug#12366: [gnu-prog-discuss] bug#12366: Writing unwritable files, Paolo Bonzini, 2012/09/07
- bug#12366: [gnu-prog-discuss] bug#12366: Writing unwritable files, Paul Eggert, 2012/09/07
- bug#12366: [gnu-prog-discuss] bug#12366: Writing unwritable files, Bob Proulx, 2012/09/07
- bug#12366: [gnu-prog-discuss] bug#12366: Writing unwritable files, Bob Friesenhahn, 2012/09/06
- bug#12366: [gnu-prog-discuss] bug#12366: Writing unwritable files, Paolo Bonzini, 2012/09/06