Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

I am the wandering glitch -- catch me if you can.


computers / comp.os.linux.misc / Contents of file changed while application is reading it

SubjectAuthor
* Contents of file changed while application is reading itClark Smith
+- Re: Contents of file changed while application is reading itRich
+* Re: Contents of file changed while application is reading itRobert Heller
|+* Re: Contents of file changed while application is reading itCarlos E.R.
||`- Re: Contents of file changed while application is reading itThe Natural Philosopher
|`* Re: Contents of file changed while application is reading itThe Natural Philosopher
| `* Re: Contents of file changed while application is reading itDavid W. Hodgins
|  +* Re: Contents of file changed while application is reading itThe Natural Philosopher
|  |+- Re: Contents of file changed while application is reading itDavid W. Hodgins
|  |`* Re: Contents of file changed while application is reading itRichard Kettlewell
|  | `* Re: Contents of file changed while application is reading itThe Natural Philosopher
|  |  +- Re: Contents of file changed while application is reading itCarlos E.R.
|  |  `- Re: Contents of file changed while application is reading itRichard Kettlewell
|  `* Re: Contents of file changed while application is reading itCarlos E.R.
|   +* Re: Contents of file changed while application is reading itRichard Kettlewell
|   |`- Re: Contents of file changed while application is reading itCarlos E.R.
|   `* Re: Contents of file changed while application is reading itThe Natural Philosopher
|    `* Re: Contents of file changed while application is reading itCarlos E.R.
|     `* Re: Contents of file changed while application is reading itThe Natural Philosopher
|      +- Re: Contents of file changed while application is reading itDavid W. Hodgins
|      +* Re: Contents of file changed while application is reading itCarlos E.R.
|      |`* Re: Contents of file changed while application is reading it28A.I873
|      | `* Re: Contents of file changed while application is reading itCarlos E.R.
|      |  `* Re: Contents of file changed while application is reading it28A.I873
|      |   +* Re: Contents of file changed while application is reading itThe Natural Philosopher
|      |   |`* Re: Contents of file changed while application is reading it28A.I873
|      |   | `* Re: Contents of file changed while application is reading itCharlie Gibbs
|      |   |  `* Re: Contents of file changed while application is reading it28A.I873
|      |   |   `* Re: Contents of file changed while application is reading itCharlie Gibbs
|      |   |    `* Re: Contents of file changed while application is reading it28A.I873
|      |   |     +- Re: Contents of file changed while application is reading itCharlie Gibbs
|      |   |     `* Re: Contents of file changed while application is reading itThe Natural Philosopher
|      |   |      `* Re: Contents of file changed while application is reading itCarlos E.R.
|      |   |       +* Re: Contents of file changed while application is reading itCharlie Gibbs
|      |   |       |+* Re: Contents of file changed while application is reading itCarlos E. R.
|      |   |       ||`* Re: Contents of file changed while application is reading itRich
|      |   |       || `- Re: Contents of file changed while application is reading itCarlos E.R.
|      |   |       |+* Re: Contents of file changed while application is reading itThe Natural Philosopher
|      |   |       ||`- Re: Contents of file changed while application is reading itCharlie Gibbs
|      |   |       |`- Re: Contents of file changed while application is reading itRich
|      |   |       `* Re: Contents of file changed while application is reading it28B.I874
|      |   |        `* Re: Contents of file changed while application is reading itCharlie Gibbs
|      |   |         +* Re: Contents of file changed while application is reading itAllodoxaphobia
|      |   |         |+* Re: Contents of file changed while application is reading itThe Natural Philosopher
|      |   |         ||`- Re: Contents of file changed while application is reading itCharlie Gibbs
|      |   |         |`- Re: Contents of file changed while application is reading it28B.I874
|      |   |         `- Re: Contents of file changed while application is reading it28B.I874
|      |   `* Re: Contents of file changed while application is reading itDavid W. Hodgins
|      |    `- Re: Contents of file changed while application is reading it28A.I873
|      `* Re: Contents of file changed while application is reading itRobert Riches
|       `* Re: Contents of file changed while application is reading itCarlos E.R.
|        `* Re: Contents of file changed while application is reading it28A.I873
|         `* Re: Contents of file changed while application is reading itThe Natural Philosopher
|          `* Re: Contents of file changed while application is reading it28A.I873
|           `* Re: Contents of file changed while application is reading itThe Natural Philosopher
|            `* Re: Contents of file changed while application is reading it28A.I873
|             `* Re: Contents of file changed while application is reading itThe Natural Philosopher
|              +* Re: Contents of file changed while application is reading itDavid W. Hodgins
|              |`* Re: Contents of file changed while application is reading it28A.I873
|              | `* Re: Contents of file changed while application is reading itThe Natural Philosopher
|              |  `- Re: Contents of file changed while application is reading it28A.I873
|              `* Re: Contents of file changed while application is reading it28A.I873
|               +* Re: Contents of file changed while application is reading itThe Natural Philosopher
|               |`- Re: Contents of file changed while application is reading it28A.I873
|               `* Re: Contents of file changed while application is reading itRichard Kettlewell
|                +* Re: Contents of file changed while application is reading itThe Natural Philosopher
|                |`* Re: Contents of file changed while application is reading itRichard Kettlewell
|                | `* Re: Contents of file changed while application is reading itThe Natural Philosopher
|                |  `* Re: Contents of file changed while application is reading itRichard Kettlewell
|                |   `- Re: Contents of file changed while application is reading itThe Natural Philosopher
|                `* Re: Contents of file changed while application is reading it28B.I874
|                 `* Re: Contents of file changed while application is reading itThe Natural Philosopher
|                  +* Re: Contents of file changed while application is reading itDan Espen
|                  |`- Re: Contents of file changed while application is reading it28B.I874
|                  `* Re: Contents of file changed while application is reading it28B.I874
|                   `* Re: Contents of file changed while application is reading itThe Natural Philosopher
|                    `- Re: Contents of file changed while application is reading it28B.I874
+* Re: Contents of file changed while application is reading itDan Espen
|+* Re: Contents of file changed while application is reading itThe Natural Philosopher
||`- Re: Contents of file changed while application is reading it28A.I873
|`- Re: Contents of file changed while application is reading itCarlos E.R.
`- Re: Contents of file changed while application is reading itThe Natural Philosopher

Pages:1234
Contents of file changed while application is reading it

<ttg9pl$301qu$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11737&group=comp.os.linux.misc#11737

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: noaddress@nowhere.net (Clark Smith)
Newsgroups: comp.os.linux.misc
Subject: Contents of file changed while application is reading it
Date: Sun, 26 Feb 2023 18:52:37 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <ttg9pl$301qu$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 26 Feb 2023 18:52:37 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="7e526813a9801d95119767444e979938";
logging-data="3147614"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ittIo04ANf4mS97F1aTw619KVeBR0k6E="
User-Agent: Pan/0.149 (Bellevue; 4c157ba git@gitlab.gnome.org:GNOME/pan.git)
Cancel-Lock: sha1:/W/baW0d+lIL39u2pB/eLH0hWW0=
 by: Clark Smith - Sun, 26 Feb 2023 18:52 UTC

Let's say that I have a C program that is reading the contents of
a file, one line at a time, with fgets(). While this is ongoing, the
contents of the file are overwritten with new data.

Is it guaranteed that the C program will continue to have access
to the old contents of the file, as long as this program keeps the
original file descriptor open?

--

Re: Contents of file changed while application is reading it

<ttgbe1$3095c$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11739&group=comp.os.linux.misc#11739

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Sun, 26 Feb 2023 19:20:33 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <ttgbe1$3095c$1@dont-email.me>
References: <ttg9pl$301qu$1@dont-email.me>
Injection-Date: Sun, 26 Feb 2023 19:20:33 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="882194fa46b8df3d1fd3a65534771be8";
logging-data="3155116"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/coirOLIurTks5fULODI40"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:WR8P76fs61vPgIcv0rsWkgCtkpc=
 by: Rich - Sun, 26 Feb 2023 19:20 UTC

Clark Smith <noaddress@nowhere.net> wrote:
> Let's say that I have a C program that is reading the contents of
> a file, one line at a time, with fgets(). While this is ongoing, the
> contents of the file are overwritten with new data.
>
> Is it guaranteed that the C program will continue to have access
> to the old contents of the file, as long as this program keeps the
> original file descriptor open?

No. Or at least no when given your minimal conditions above (no
locking stated, no coordination between reader and writer stated).

Re: Contents of file changed while application is reading it

<DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11745&group=comp.os.linux.misc#11745

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.snarked.org!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sun, 26 Feb 2023 21:45:28 +0000
MIME-Version: 1.0
From: heller@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.15)
Subject: Re: Contents of file changed while application is reading it
In-Reply-To: <ttg9pl$301qu$1@dont-email.me>
References: <ttg9pl$301qu$1@dont-email.me>
Newsgroups: comp.os.linux.misc
Content-Type: text/plain;
charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
Date: Sun, 26 Feb 2023 21:45:28 +0000
Lines: 25
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-nx0JkZVi8JcqlkqH9mNDuxVvI5aiY3TETF/ZkG4Ac0Yb3EpnCPvOY2zhN8EvTCePAE5fprL22837eDj!Fh5WNS5Jbu+uKuxsk3RMkc0ny7pb9aj+Ty8DLgdmWygtLTVkJK7U1SPJtOYMG2/8grEiSA3gY3rE!tTY=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Robert Heller - Sun, 26 Feb 2023 21:45 UTC

At Sun, 26 Feb 2023 18:52:37 -0000 (UTC) Clark Smith <noaddress@nowhere.net> wrote:

>
> Let's say that I have a C program that is reading the contents of
> a file, one line at a time, with fgets(). While this is ongoing, the
> contents of the file are overwritten with new data.
>
> Is it guaranteed that the C program will continue to have access
> to the old contents of the file, as long as this program keeps the
> original file descriptor open?

Generally yes.

>
>
>
>
>

--
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
heller@deepsoft.com -- Webhosting Services

Re: Contents of file changed while application is reading it

<3n1tcjxfgv.ln2@Telcontar.valinor>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11746&group=comp.os.linux.misc#11746

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: robin_listas@es.invalid (Carlos E.R.)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Sun, 26 Feb 2023 23:05:55 +0100
Lines: 22
Message-ID: <3n1tcjxfgv.ln2@Telcontar.valinor>
References: <ttg9pl$301qu$1@dont-email.me>
<DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net MvHT18Pru9p5M6CP30Evzg7F7oEa68ymhXnk7vtZ95fUQPsAnF
X-Orig-Path: Telcontar.valinor!not-for-mail
Cancel-Lock: sha1:ETw1JjiCqnk0xYiFZKwrXyW7/zU=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Content-Language: es-ES, en-CA
In-Reply-To: <DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
 by: Carlos E.R. - Sun, 26 Feb 2023 22:05 UTC

On 2023-02-26 22:45, Robert Heller wrote:
> At Sun, 26 Feb 2023 18:52:37 -0000 (UTC) Clark Smith <noaddress@nowhere.net> wrote:
>
>>
>> Let's say that I have a C program that is reading the contents of
>> a file, one line at a time, with fgets(). While this is ongoing, the
>> contents of the file are overwritten with new data.
>>
>> Is it guaranteed that the C program will continue to have access
>> to the old contents of the file, as long as this program keeps the
>> original file descriptor open?
>
> Generally yes.

Or not.

Take a script that runs for long. Edit it while running, the script
usually errors out. Bash.

--
Cheers, Carlos.

Re: Contents of file changed while application is reading it

<ttgms9$31hl4$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11749&group=comp.os.linux.misc#11749

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: dan1espen@gmail.com (Dan Espen)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Sun, 26 Feb 2023 17:35:53 -0500
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <ttgms9$31hl4$1@dont-email.me>
References: <ttg9pl$301qu$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="1c084abfefa58c3ae9d838f147707e34";
logging-data="3196580"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19NJ1getQXtFNiIMZSUIHwPwC/Dwsoikz0="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux)
Cancel-Lock: sha1:ERB96zMAW6aqi4L9u156gaPxHxc=
 by: Dan Espen - Sun, 26 Feb 2023 22:35 UTC

Clark Smith <noaddress@nowhere.net> writes:

> Let's say that I have a C program that is reading the contents of
> a file, one line at a time, with fgets(). While this is ongoing, the
> contents of the file are overwritten with new data.
>
> Is it guaranteed that the C program will continue to have access
> to the old contents of the file, as long as this program keeps the
> original file descriptor open?

If the original file is deleted and a new file created any programs
that have the old file open won't see any changes. The file is really
deleted after all the programs using it close the file.

If the file is actually being updated in place the program will see data
change subject to buffering issues.

--
Dan Espen

Re: Contents of file changed while application is reading it

<ttgq4r$279gm$24@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11752&group=comp.os.linux.misc#11752

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: tnp@invalid.invalid (The Natural Philosopher)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Sun, 26 Feb 2023 23:31:39 +0000
Organization: A little, after lunch
Lines: 38
Message-ID: <ttgq4r$279gm$24@dont-email.me>
References: <ttg9pl$301qu$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 26 Feb 2023 23:31:39 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="4655b826320e8b98b9b7b1a215967df9";
logging-data="2336278"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19PHBxePwAcUXrPmeGSi/btMQcgWxc25O8="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Cancel-Lock: sha1:MWLQZoSf3SLZtrUfC3TB14zcQao=
In-Reply-To: <ttg9pl$301qu$1@dont-email.me>
Content-Language: en-GB
 by: The Natural Philosop - Sun, 26 Feb 2023 23:31 UTC

On 26/02/2023 18:52, Clark Smith wrote:
> Let's say that I have a C program that is reading the contents of
> a file, one line at a time, with fgets(). While this is ongoing, the
> contents of the file are overwritten with new data.
>
> Is it guaranteed that the C program will continue to have access
> to the old contents of the file, as long as this program keeps the
> original file descriptor open?
>
>
I would say almost certainly not.

A file that is being simultaneously read and written too without some
form of semaphore will give indeterminate results depending on timings
of asynchronous processes.

In all probabilty the read will be heavily cached, yes, but I would
except that cache to be writeable to in real time before being read.

In short of you read an extent from a file, write the next extent, and
then read it, you will get new data, not old.

If you want to preserve all the old data, program a lock on the file,
explicitly load it into memory or duplicate the file and when don.,
remove the lock.

>
>
>

--
For in reason, all government without the consent of the governed is the
very definition of slavery.

Jonathan Swift

Re: Contents of file changed while application is reading it

<ttgq6m$279gm$25@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11753&group=comp.os.linux.misc#11753

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: tnp@invalid.invalid (The Natural Philosopher)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Sun, 26 Feb 2023 23:32:38 +0000
Organization: A little, after lunch
Lines: 25
Message-ID: <ttgq6m$279gm$25@dont-email.me>
References: <ttg9pl$301qu$1@dont-email.me>
<DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 26 Feb 2023 23:32:39 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="4655b826320e8b98b9b7b1a215967df9";
logging-data="2336278"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Faj6bPQsKv8XsVz81AXSOaONrvkSZAF4="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Cancel-Lock: sha1:TpAqkhUbpYK1TQNKQKDYCU45kKc=
In-Reply-To: <DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
Content-Language: en-GB
 by: The Natural Philosop - Sun, 26 Feb 2023 23:32 UTC

On 26/02/2023 21:45, Robert Heller wrote:
> At Sun, 26 Feb 2023 18:52:37 -0000 (UTC) Clark Smith <noaddress@nowhere.net> wrote:
>
>>
>> Let's say that I have a C program that is reading the contents of
>> a file, one line at a time, with fgets(). While this is ongoing, the
>> contents of the file are overwritten with new data.
>>
>> Is it guaranteed that the C program will continue to have access
>> to the old contents of the file, as long as this program keeps the
>> original file descriptor open?
>
> Generally yes.

I am pretty sure generally NO.

Otherwise databases would have a hard time working

--
For in reason, all government without the consent of the governed is the
very definition of slavery.

Jonathan Swift

Re: Contents of file changed while application is reading it

<ttgqh0$279gm$26@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11754&group=comp.os.linux.misc#11754

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: tnp@invalid.invalid (The Natural Philosopher)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Sun, 26 Feb 2023 23:38:08 +0000
Organization: A little, after lunch
Lines: 39
Message-ID: <ttgqh0$279gm$26@dont-email.me>
References: <ttg9pl$301qu$1@dont-email.me>
<DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
<3n1tcjxfgv.ln2@Telcontar.valinor>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 26 Feb 2023 23:38:08 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="4655b826320e8b98b9b7b1a215967df9";
logging-data="2336278"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18uQM6PVtw1unRuoZ4RFQbDsW61SNlOoPo="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Cancel-Lock: sha1:Yh8LG1W8poAovM3tZFiEUc1w1Dc=
In-Reply-To: <3n1tcjxfgv.ln2@Telcontar.valinor>
Content-Language: en-GB
 by: The Natural Philosop - Sun, 26 Feb 2023 23:38 UTC

On 26/02/2023 22:05, Carlos E.R. wrote:
> On 2023-02-26 22:45, Robert Heller wrote:
>> At Sun, 26 Feb 2023 18:52:37 -0000 (UTC) Clark Smith
>> <noaddress@nowhere.net> wrote:
>>
>>>
>>>     Let's say that I have a C program that is reading the contents of
>>> a file, one line at a time, with fgets(). While this is ongoing, the
>>> contents of the file are overwritten with new data.
>>>
>>>     Is it guaranteed that the C program will continue to have access
>>> to the old contents of the file, as long as this program keeps the
>>> original file descriptor open?
>>
>> Generally yes.
>
> Or not.
>
> Take a script that runs for long. Edit it while running, the script
> usually errors out. Bash.
>
The edit process probably writes a new file and erases the old.

I've certainly used and am using files on a small RAMdisk as a way for
two processes to communicate on a 'I write, you read' basis.
The writer is am icecast interpreter reading program data off an MP3
icecast stream, the reader is an Ajax process polling a piece of web
server to update the screen of an audioplayer app.

Ok in this case the reader opens the file reads it and closes it.

--
For in reason, all government without the consent of the governed is the
very definition of slavery.

Jonathan Swift

Re: Contents of file changed while application is reading it

<ttgqj6$279gm$27@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11755&group=comp.os.linux.misc#11755

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: tnp@invalid.invalid (The Natural Philosopher)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Sun, 26 Feb 2023 23:39:18 +0000
Organization: A little, after lunch
Lines: 33
Message-ID: <ttgqj6$279gm$27@dont-email.me>
References: <ttg9pl$301qu$1@dont-email.me> <ttgms9$31hl4$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 26 Feb 2023 23:39:18 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="4655b826320e8b98b9b7b1a215967df9";
logging-data="2336278"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19R/4yylsLDfI0U6vCq05z5GdW11iz8bAo="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Cancel-Lock: sha1:oQblnKDa5MDq25QJPJbf+Hw8P/8=
Content-Language: en-GB
In-Reply-To: <ttgms9$31hl4$1@dont-email.me>
 by: The Natural Philosop - Sun, 26 Feb 2023 23:39 UTC

On 26/02/2023 22:35, Dan Espen wrote:
> Clark Smith <noaddress@nowhere.net> writes:
>
>> Let's say that I have a C program that is reading the contents of
>> a file, one line at a time, with fgets(). While this is ongoing, the
>> contents of the file are overwritten with new data.
>>
>> Is it guaranteed that the C program will continue to have access
>> to the old contents of the file, as long as this program keeps the
>> original file descriptor open?
>
> If the original file is deleted and a new file created any programs
> that have the old file open won't see any changes. The file is really
> deleted after all the programs using it close the file.
>
> If the file is actually being updated in place the program will see data
> change subject to buffering issues.
>
+1.

That's the neatest way of describing it 'subject to buffering issues'
hides a whole slew of complexity. :-)

--
Those who want slavery should have the grace to name it by its proper
name. They must face the full meaning of that which they are advocating
or condoning; the full, exact, specific meaning of collectivism, of its
logical implications, of the principles upon which it is based, and of
the ultimate consequences to which these principles will lead. They must
face it, then decide whether this is what they want or not.

Ayn Rand.

Re: Contents of file changed while application is reading it

<op.10zzw9sea3w0dxdave@hodgins.homeip.net>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11756&group=comp.os.linux.misc#11756

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: dwhodgins@nomail.afraid.org (David W. Hodgins)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Sun, 26 Feb 2023 19:06:35 -0500
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <op.10zzw9sea3w0dxdave@hodgins.homeip.net>
References: <ttg9pl$301qu$1@dont-email.me>
<DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
<ttgq6m$279gm$25@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8bit
Injection-Info: reader01.eternal-september.org; posting-host="51f39f4b271dce7fd0755dd894f3bfa4";
logging-data="3215583"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+3WyTzEEWtg6pJ75g4TcRYEDAHFytC1zg="
User-Agent: Opera Mail/12.16 (Linux)
Cancel-Lock: sha1:gzSK0CEaJPMV9bEvzfMampVMxfk=
 by: David W. Hodgins - Mon, 27 Feb 2023 00:06 UTC

On Sun, 26 Feb 2023 18:32:38 -0500, The Natural Philosopher <tnp@invalid.invalid> wrote:
> I am pretty sure generally NO.
> Otherwise databases would have a hard time working

Data base applications work by having one thread that does the physical i/o for
each file that contains the database. Multiple applications can use the database,
but they don't do the i/o to the disk.

For other files, applications that load the entire file into ram, and then write
a new copy, the old inode/file will remain until all applications that have the
file open have finished, so those files can be read ok regardless of buffering.

For applications that update the file in place, corruption can occur for other
applications reading that file using buffering.

Regards, Dave Hodgins

Re: Contents of file changed while application is reading it

<ttgtcg$279gm$36@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11757&group=comp.os.linux.misc#11757

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: tnp@invalid.invalid (The Natural Philosopher)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Mon, 27 Feb 2023 00:26:56 +0000
Organization: A little, after lunch
Lines: 63
Message-ID: <ttgtcg$279gm$36@dont-email.me>
References: <ttg9pl$301qu$1@dont-email.me>
<DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
<ttgq6m$279gm$25@dont-email.me> <op.10zzw9sea3w0dxdave@hodgins.homeip.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 27 Feb 2023 00:26:56 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="4655b826320e8b98b9b7b1a215967df9";
logging-data="2336278"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+iVOiR0R08IeZbiX2qM+R4C1xzhcO+Ihc="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Cancel-Lock: sha1:a4EuJbAQelfL2IIGFuNlaBXCZ60=
Content-Language: en-GB
In-Reply-To: <op.10zzw9sea3w0dxdave@hodgins.homeip.net>
 by: The Natural Philosop - Mon, 27 Feb 2023 00:26 UTC

On 27/02/2023 00:06, David W. Hodgins wrote:
> On Sun, 26 Feb 2023 18:32:38 -0500, The Natural Philosopher
> <tnp@invalid.invalid> wrote:
>> I am pretty sure generally NO. Otherwise databases would have a
>> hard time working
>
> Data base applications work by having one thread that does the
> physical i/o for each file that contains the database. Multiple
> applications can use the database, but they don't do the i/o to the
> disk.
>
> For other files, applications that load the entire file into ram, and
> then write a new copy, the old inode/file will remain until all
> applications that have the file open have finished, so those files
> can be read ok regardless of buffering.
Straw man.
That is not the case the OP was talking about. Its the one you happen to
know about, but put it away and don't show off

The issue is a file that has two file descriptors in two processes which
are reading and writing to its extents simultaneously.
How much is cached *in program* is the issue, because at the OS level
disk caches will be read and written by and shared by both processes.

It is entirely analogous to a database that doesn't serialise the
processes consistently.

So you cant tell if a given process will complete a write, before the
other process calls for a read.

Whether those reads and writes are actually to the cache or the disk is
supremely irrelevant as are inodes and file sand directories. We are
talking about a file that is open and not being closed by two concurrent
processes.
IIRC a C style fread() or fwrite() goes straight to the OS and so there
is no in program caching below that level, only OS disk caching which is
invisible to the application

So if process A does an fseek(X), fwrite() and process B then does
fseek(X), fread() of the same data extent, the last written value will
be read.

>
> For applications that update the file in place, corruption can occur
> for other applications reading that file using buffering.
>
What buffereing?
If you read the whole file into application RAM., of course you are
immune from changes made to it subsequently.

But if you are simply using fseek() and fread () to access extents of
the file, you will get whatever the last data put there is.

> Regards, Dave Hodgins

--
"Anyone who believes that the laws of physics are mere social
conventions is invited to try transgressing those conventions from the
windows of my apartment. (I live on the twenty-first floor.) "

Alan Sokal

Re: Contents of file changed while application is reading it

<op.10z4mfk2a3w0dxdave@hodgins.homeip.net>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11758&group=comp.os.linux.misc#11758

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: dwhodgins@nomail.afraid.org (David W. Hodgins)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Sun, 26 Feb 2023 20:48:05 -0500
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <op.10z4mfk2a3w0dxdave@hodgins.homeip.net>
References: <ttg9pl$301qu$1@dont-email.me>
<DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
<ttgq6m$279gm$25@dont-email.me> <op.10zzw9sea3w0dxdave@hodgins.homeip.net>
<ttgtcg$279gm$36@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8bit
Injection-Info: reader01.eternal-september.org; posting-host="51f39f4b271dce7fd0755dd894f3bfa4";
logging-data="3231432"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19XCnh7tYglXXDmZ1lHOg7N6NkWB1rjYbI="
User-Agent: Opera Mail/12.16 (Linux)
Cancel-Lock: sha1:QC+gi0P7bNUqOl7SFUQBdby+TkQ=
 by: David W. Hodgins - Mon, 27 Feb 2023 01:48 UTC

On Sun, 26 Feb 2023 19:26:56 -0500, The Natural Philosopher <tnp@invalid.invalid> wrote:
> The issue is a file that has two file descriptors in two processes which
> are reading and writing to its extents simultaneously.
> How much is cached *in program* is the issue, because at the OS level
> disk caches will be read and written by and shared by both processes.
>
> It is entirely analogous to a database that doesn't serialise the
> processes consistently.
>
> So you cant tell if a given process will complete a write, before the
> other process calls for a read.
>
> Whether those reads and writes are actually to the cache or the disk is
> supremely irrelevant as are inodes and file sand directories. We are
> talking about a file that is open and not being closed by two concurrent
> processes.
> IIRC a C style fread() or fwrite() goes straight to the OS and so there
> is no in program caching below that level, only OS disk caching which is
> invisible to the application

Multiple applications can read/write the same file in place, but they must
have some way of co-ordinating which parts of the file each can update.

There are many ways it can safely be done, but if not done in a safe manner
will lead to data corruption.

> So if process A does an fseek(X), fwrite() and process B then does
> fseek(X), fread() of the same data extent, the last written value will
> be read.
>
>>
>> For applications that update the file in place, corruption can occur
>> for other applications reading that file using buffering.
>>
> What buffereing?

> If you read the whole file into application RAM., of course you are
> immune from changes made to it subsequently.

Buffering is the alternative to reading the whole file into ram. I.E. reading
one part at a time.

The example given earlier in this thread is bash scripts. Bash use buffering.
If the entire script fits in one buffer, great. If it's larger, then updating
the script while it's being run will most likely cause problems.

> But if you are simply using fseek() and fread () to access extents of
> the file, you will get whatever the last data put there is.

With unsafe handling, two applications read the same data, one makes changes and
writes it, the other makes other changes and writes it. The first applications
changes are lost.

At the hardware level, i/o is done with 512 or 4096 byte sectors. That is the
minimum size block two r/w applications must co-ordinate writing to ensure
changes are not lost. It can be ownership maps, serialized locks of blocks,
notification that a block is being changed, etc. There are many ways it can
be done, but if it isn't being done data loss is a risk.

Regards, Dave Hodgins

Re: Contents of file changed while application is reading it

<di6dnQySFJwsu2H-nZ2dnZfqnPidnZ2d@earthlink.com>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11759&group=comp.os.linux.misc#11759

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail
NNTP-Posting-Date: Mon, 27 Feb 2023 03:42:41 +0000
Subject: Re: Contents of file changed while application is reading it
Newsgroups: comp.os.linux.misc
References: <ttg9pl$301qu$1@dont-email.me> <ttgms9$31hl4$1@dont-email.me>
<ttgqj6$279gm$27@dont-email.me>
From: 28A.I873@noabzba.net (28A.I873)
Organization: mitotic resell
Date: Sun, 26 Feb 2023 22:42:40 -0500
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
MIME-Version: 1.0
In-Reply-To: <ttgqj6$279gm$27@dont-email.me>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Message-ID: <di6dnQySFJwsu2H-nZ2dnZfqnPidnZ2d@earthlink.com>
Lines: 42
X-Usenet-Provider: http://www.giganews.com
NNTP-Posting-Host: 68.222.41.46
X-Trace: sv3-2DSIZPzt6ju1k3Tfz3H7boVK/BNqABUSHrEH/Hz7Fi6YFSWsbn+khQtPtetCuXarXw7QFJ32hGFWeWv!gXGmx0B1Fi+lG6rBsmzvU7r//dX+e77P1hDAub9e+hV0er22CV2hwKmu2KtFyNNCbYeYXmYwnQM4!EQe71cVTjXI4AshJ6LQ=
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: 28A.I873 - Mon, 27 Feb 2023 03:42 UTC

On 2/26/23 6:39 PM, The Natural Philosopher wrote:
> On 26/02/2023 22:35, Dan Espen wrote:
>> Clark Smith <noaddress@nowhere.net> writes:
>>
>>>     Let's say that I have a C program that is reading the contents of
>>> a file, one line at a time, with fgets(). While this is ongoing, the
>>> contents of the file are overwritten with new data.
>>>
>>>     Is it guaranteed that the C program will continue to have access
>>> to the old contents of the file, as long as this program keeps the
>>> original file descriptor open?
>>
>> If the original file is deleted and a new file created any programs
>> that have the old file open won't see any changes.  The file is really
>> deleted after all the programs using it close the file.
>>
>> If the file is actually being updated in place the program will see data
>> change subject to buffering issues.
>>
> +1.
>
> That's the neatest way of describing it 'subject to buffering issues'
> hides a whole slew of complexity. :-)

And thus we understand the often-complex file/record-locking
tricks things like multiuser databases do :-)

If your app (or subthread) loads a buffer from File-X and then
another app (or subthread) alters File-X, YOU don't really
KNOW about it ... you're working on an obsolete buffer. Some
smarter apps check if something about the file has changed ...
but any edits you were doing on the obsolete version HAVE to
be thrown out. If a bunch of apps/subthreads are working on
the file at the same time it becomes HOPELESS. Locks are
the easiest approach.

"Shared buffers" - something ALL users can access/edit at the
exact same time - live updating - are also possible but more
work. Some "collaborative" apps seem to use this approach. You
type in something, everybody sees their text/whatever change
too. Edit-wars are possible ... kinda like with WikiPedia :-)

Re: Contents of file changed while application is reading it

<wwv8rgjscnf.fsf@LkoBDZeT.terraraq.uk>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11765&group=comp.os.linux.misc#11765

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!nntp.terraraq.uk!.POSTED.tunnel.sfere.anjou.terraraq.org.uk!not-for-mail
From: invalid@invalid.invalid (Richard Kettlewell)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Mon, 27 Feb 2023 09:03:48 +0000
Organization: terraraq NNTP server
Message-ID: <wwv8rgjscnf.fsf@LkoBDZeT.terraraq.uk>
References: <ttg9pl$301qu$1@dont-email.me>
<DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
<ttgq6m$279gm$25@dont-email.me>
<op.10zzw9sea3w0dxdave@hodgins.homeip.net>
<ttgtcg$279gm$36@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: innmantic.terraraq.uk; posting-host="tunnel.sfere.anjou.terraraq.org.uk:172.17.207.6";
logging-data="8751"; mail-complaints-to="usenet@innmantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:brHzMOv3fqQUNBFtC80kjGh/uQ4=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
+r0NzP?vnz:e/knOY)PI-
X-Boydie: NO
 by: Richard Kettlewell - Mon, 27 Feb 2023 09:03 UTC

The Natural Philosopher <tnp@invalid.invalid> writes:
> IIRC a C style fread() or fwrite() goes straight to the OS and so
> there is no in program caching below that level, only OS disk caching
> which is invisible to the application

You are thinking of read() and write() here - fread() & fwrite() will
use the process’s own buffer (unless you deliberately made the file
unbuffered).

A network filesystem (e.g. NFS with the async option) may also break
cache consistency.

--
https://www.greenend.org.uk/rjk/

Re: Contents of file changed while application is reading it

<t2aucjxrkf.ln2@Telcontar.valinor>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11766&group=comp.os.linux.misc#11766

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: robin_listas@es.invalid (Carlos E.R.)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Mon, 27 Feb 2023 10:34:53 +0100
Lines: 28
Message-ID: <t2aucjxrkf.ln2@Telcontar.valinor>
References: <ttg9pl$301qu$1@dont-email.me>
<DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
<ttgq6m$279gm$25@dont-email.me> <op.10zzw9sea3w0dxdave@hodgins.homeip.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net jAN7dL8czwi6mHSCILiprgYA//FjPNG7G699cTWhEgQaUedeS1
X-Orig-Path: Telcontar.valinor!not-for-mail
Cancel-Lock: sha1:BlCd4gh+pm/1A8DN9sjfvkun1Bc=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Content-Language: es-ES, en-CA
In-Reply-To: <op.10zzw9sea3w0dxdave@hodgins.homeip.net>
 by: Carlos E.R. - Mon, 27 Feb 2023 09:34 UTC

On 2023-02-27 01:06, David W. Hodgins wrote:
> On Sun, 26 Feb 2023 18:32:38 -0500, The Natural Philosopher
> <tnp@invalid.invalid> wrote:
>> I am pretty sure generally NO.
>> Otherwise databases would have a hard time working
>
> Data base applications work by having one thread that does the
> physical i/o for each file that contains the database. Multiple
> applications can use the database, but they don't do the i/o to the
> disk.

Not all database applications work that way.

For example, in MsDOS an application could lock for write a section of a
file, write that, then remove the lock. Another application could be
reading the same file, even writing in another section.

This functionality was an add on: you needed to run the optional
share.exe. But Windows had it natively.

I believe Microsoft Access works like that.

I am not sure this behaviour can be done in Linux. Long ago it could not.

--
Cheers, Carlos.

Re: Contents of file changed while application is reading it

<5naucjx3rg.ln2@Telcontar.valinor>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11767&group=comp.os.linux.misc#11767

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: robin_listas@es.invalid (Carlos E.R.)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Mon, 27 Feb 2023 10:45:41 +0100
Lines: 29
Message-ID: <5naucjx3rg.ln2@Telcontar.valinor>
References: <ttg9pl$301qu$1@dont-email.me> <ttgms9$31hl4$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net C3BBgVUvn50pykxi8mPvuA2MBjcs7UCZTq9dRzMsz1zSmYpkp2
X-Orig-Path: Telcontar.valinor!not-for-mail
Cancel-Lock: sha1:xohsDKsngZewa9okpxmOKlLCNWY=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Content-Language: es-ES, en-CA
In-Reply-To: <ttgms9$31hl4$1@dont-email.me>
 by: Carlos E.R. - Mon, 27 Feb 2023 09:45 UTC

On 2023-02-26 23:35, Dan Espen wrote:
> Clark Smith <noaddress@nowhere.net> writes:
>
>> Let's say that I have a C program that is reading the contents of
>> a file, one line at a time, with fgets(). While this is ongoing, the
>> contents of the file are overwritten with new data.
>>
>> Is it guaranteed that the C program will continue to have access
>> to the old contents of the file, as long as this program keeps the
>> original file descriptor open?
>
> If the original file is deleted and a new file created any programs
> that have the old file open won't see any changes. The file is really
> deleted after all the programs using it close the file.

If the first program keeps the file opened, it can not be actually
deleted in a Linux filesystem. The first program keeps reading the old
file till it closes it.

lsof lists them, and marks "deleted" files.

> If the file is actually being updated in place the program will see data
> change subject to buffering issues.
>

--
Cheers, Carlos.

Re: Contents of file changed while application is reading it

<wwvilfn8mlt.fsf@LkoBDZeT.terraraq.uk>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11768&group=comp.os.linux.misc#11768

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!nntp.terraraq.uk!.POSTED.tunnel.sfere.anjou.terraraq.org.uk!not-for-mail
From: invalid@invalid.invalid (Richard Kettlewell)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Mon, 27 Feb 2023 09:49:02 +0000
Organization: terraraq NNTP server
Message-ID: <wwvilfn8mlt.fsf@LkoBDZeT.terraraq.uk>
References: <ttg9pl$301qu$1@dont-email.me>
<DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
<ttgq6m$279gm$25@dont-email.me>
<op.10zzw9sea3w0dxdave@hodgins.homeip.net>
<t2aucjxrkf.ln2@Telcontar.valinor>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: innmantic.terraraq.uk; posting-host="tunnel.sfere.anjou.terraraq.org.uk:172.17.207.6";
logging-data="9325"; mail-complaints-to="usenet@innmantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:DufFZXhHYvAH8NZ9YtiXSjGcoos=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
+r0NzP?vnz:e/knOY)PI-
X-Boydie: NO
 by: Richard Kettlewell - Mon, 27 Feb 2023 09:49 UTC

"Carlos E.R." <robin_listas@es.invalid> writes:
> For example, in MsDOS an application could lock for write a section of
> a file, write that, then remove the lock. Another application could be
> reading the same file, even writing in another section.
>
> This functionality was an add on: you needed to run the optional
> share.exe. But Windows had it natively.
>
> I believe Microsoft Access works like that.
>
>
> I am not sure this behaviour can be done in Linux. Long ago it could
> not.

Discretionary file locking has existed on Linux for as long as I can
remember. Mandatory locking existed in Linux at one point but apparently
was too buggy to be usable in practice, and was removed in Linux 5.15.

--
https://www.greenend.org.uk/rjk/

Re: Contents of file changed while application is reading it

<tthusr$27bbi$21@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11769&group=comp.os.linux.misc#11769

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: tnp@invalid.invalid (The Natural Philosopher)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Mon, 27 Feb 2023 09:58:51 +0000
Organization: A little, after lunch
Lines: 29
Message-ID: <tthusr$27bbi$21@dont-email.me>
References: <ttg9pl$301qu$1@dont-email.me>
<DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
<ttgq6m$279gm$25@dont-email.me> <op.10zzw9sea3w0dxdave@hodgins.homeip.net>
<ttgtcg$279gm$36@dont-email.me> <wwv8rgjscnf.fsf@LkoBDZeT.terraraq.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 27 Feb 2023 09:58:52 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="4655b826320e8b98b9b7b1a215967df9";
logging-data="2338162"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX181Nx7NH+MTCeCIlkjh29kylm8E7Hgtnyo="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Cancel-Lock: sha1:huxp6FN/kNaILAihQzc5eLOPxqA=
Content-Language: en-GB
In-Reply-To: <wwv8rgjscnf.fsf@LkoBDZeT.terraraq.uk>
 by: The Natural Philosop - Mon, 27 Feb 2023 09:58 UTC

On 27/02/2023 09:03, Richard Kettlewell wrote:
> The Natural Philosopher <tnp@invalid.invalid> writes:
>> IIRC a C style fread() or fwrite() goes straight to the OS and so
>> there is no in program caching below that level, only OS disk caching
>> which is invisible to the application
>
> You are thinking of read() and write() here - fread() & fwrite() will
> use the process’s own buffer (unless you deliberately made the file
> unbuffered).
>
Well yes and no, I was not aware that processes had their own buffers
*below* fread/fwrite level.

> A network filesystem (e.g. NFS with the async option) may also break
> cache consistency.
>

Even more complexity. :)

--
“People believe certain stories because everyone important tells them,
and people tell those stories because everyone important believes them.
Indeed, when a conventional wisdom is at its fullest strength, one’s
agreement with that conventional wisdom becomes almost a litmus test of
one’s suitability to be taken seriously.”

Paul Krugman

Re: Contents of file changed while application is reading it

<tthv4d$27bbi$22@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11770&group=comp.os.linux.misc#11770

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: tnp@invalid.invalid (The Natural Philosopher)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Mon, 27 Feb 2023 10:02:53 +0000
Organization: A little, after lunch
Lines: 47
Message-ID: <tthv4d$27bbi$22@dont-email.me>
References: <ttg9pl$301qu$1@dont-email.me>
<DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
<ttgq6m$279gm$25@dont-email.me> <op.10zzw9sea3w0dxdave@hodgins.homeip.net>
<t2aucjxrkf.ln2@Telcontar.valinor>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 27 Feb 2023 10:02:53 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="4655b826320e8b98b9b7b1a215967df9";
logging-data="2338162"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19yUjm6Yp4fG0F8QLG7/U2AoYqoghFaBQw="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Cancel-Lock: sha1:4WHzI1Tyl/oMtjBubpAEC69Iv5I=
Content-Language: en-GB
In-Reply-To: <t2aucjxrkf.ln2@Telcontar.valinor>
 by: The Natural Philosop - Mon, 27 Feb 2023 10:02 UTC

On 27/02/2023 09:34, Carlos E.R. wrote:
> On 2023-02-27 01:06, David W. Hodgins wrote:
>> On Sun, 26 Feb 2023 18:32:38 -0500, The Natural Philosopher
>> <tnp@invalid.invalid> wrote:
>>> I am pretty sure generally NO.
>>> Otherwise databases would have a hard time working
>>
>> Data base applications work by having one thread that does the
>> physical i/o for each file that contains the database. Multiple
>> applications can use the database, but they don't do the i/o to the
>> disk.
>
> Not all database applications work that way.
>
> For example, in MsDOS an application could lock for write a section of a
> file, write that, then remove the lock. Another application could be
> reading the same file, even writing in another section.
>
> This functionality was an add on: you needed to run the optional
> share.exe. But Windows had it natively.
>
> I believe Microsoft Access works like that.
>
>
> I am not sure this behaviour can be done in Linux. Long ago it could not.
>
File lockining always existed at the level of IIRC whole files.
But obliviously it is far far easier to have a databse engine accepting
all requests and using (at least) just one process, if not one thread,
to do all I/O

Even then things get tricky.
Consider you have placed an item on your 'basket' on a shipping app, on
the basies that there are 2 in stock, go make a cup of coffeee, come
back and try to checkout to find there are now none.

--
“People believe certain stories because everyone important tells them,
and people tell those stories because everyone important believes them.
Indeed, when a conventional wisdom is at its fullest strength, one’s
agreement with that conventional wisdom becomes almost a litmus test of
one’s suitability to be taken seriously.”

Paul Krugman

Re: Contents of file changed while application is reading it

<gbcucjxlnh.ln2@Telcontar.valinor>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11771&group=comp.os.linux.misc#11771

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: robin_listas@es.invalid (Carlos E.R.)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Mon, 27 Feb 2023 11:13:36 +0100
Lines: 25
Message-ID: <gbcucjxlnh.ln2@Telcontar.valinor>
References: <ttg9pl$301qu$1@dont-email.me>
<DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
<ttgq6m$279gm$25@dont-email.me> <op.10zzw9sea3w0dxdave@hodgins.homeip.net>
<t2aucjxrkf.ln2@Telcontar.valinor> <wwvilfn8mlt.fsf@LkoBDZeT.terraraq.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net I3smEyLivPyNS42BqU8HmQigoj/Tulxvxf3RmfTQLbjd7yQxoo
X-Orig-Path: Telcontar.valinor!not-for-mail
Cancel-Lock: sha1:dE+43NYRoxGTmP13CY6qVstn3pQ=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Content-Language: es-ES, en-CA
In-Reply-To: <wwvilfn8mlt.fsf@LkoBDZeT.terraraq.uk>
 by: Carlos E.R. - Mon, 27 Feb 2023 10:13 UTC

On 2023-02-27 10:49, Richard Kettlewell wrote:
> "Carlos E.R." <robin_listas@es.invalid> writes:
>> For example, in MsDOS an application could lock for write a section of
>> a file, write that, then remove the lock. Another application could be
>> reading the same file, even writing in another section.
>>
>> This functionality was an add on: you needed to run the optional
>> share.exe. But Windows had it natively.
>>
>> I believe Microsoft Access works like that.
>>
>>
>> I am not sure this behaviour can be done in Linux. Long ago it could
>> not.
>
> Discretionary file locking has existed on Linux for as long as I can
> remember. Mandatory locking existed in Linux at one point but apparently
> was too buggy to be usable in practice, and was removed in Linux 5.15.
>

In MsDOS was mandatory (if the exe had loaded).

--
Cheers, Carlos.

Re: Contents of file changed while application is reading it

<vacucjxlnh.ln2@Telcontar.valinor>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11772&group=comp.os.linux.misc#11772

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: robin_listas@es.invalid (Carlos E.R.)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Mon, 27 Feb 2023 11:13:19 +0100
Lines: 46
Message-ID: <vacucjxlnh.ln2@Telcontar.valinor>
References: <ttg9pl$301qu$1@dont-email.me>
<DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
<ttgq6m$279gm$25@dont-email.me> <op.10zzw9sea3w0dxdave@hodgins.homeip.net>
<t2aucjxrkf.ln2@Telcontar.valinor> <tthv4d$27bbi$22@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net tQVSVH36q6FJAZwwTCXhgQ59VfUbypLjM4k89ei+H4Y2rUiDAM
X-Orig-Path: Telcontar.valinor!not-for-mail
Cancel-Lock: sha1:AReqI+NUVSNoujBctxJsIHJkDDs=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Content-Language: es-ES, en-CA
In-Reply-To: <tthv4d$27bbi$22@dont-email.me>
 by: Carlos E.R. - Mon, 27 Feb 2023 10:13 UTC

On 2023-02-27 11:02, The Natural Philosopher wrote:
> On 27/02/2023 09:34, Carlos E.R. wrote:
>> On 2023-02-27 01:06, David W. Hodgins wrote:
>>> On Sun, 26 Feb 2023 18:32:38 -0500, The Natural Philosopher
>>> <tnp@invalid.invalid> wrote:
>>>> I am pretty sure generally NO.
>>>> Otherwise databases would have a hard time working
>>>
>>> Data base applications work by having one thread that does the
>>> physical i/o for each file that contains the database. Multiple
>>> applications can use the database, but they don't do the i/o to the
>>> disk.
>>
>> Not all database applications work that way.
>>
>> For example, in MsDOS an application could lock for write a section of
>> a file, write that, then remove the lock. Another application could be
>> reading the same file, even writing in another section.
>>
>> This functionality was an add on: you needed to run the optional
>> share.exe. But Windows had it natively.
>>
>> I believe Microsoft Access works like that.
>>
>>
>> I am not sure this behaviour can be done in Linux. Long ago it could not.
>>
> File lockining always existed at the level of IIRC whole files.
> But obliviously it is far far easier to have a databse engine accepting
> all requests and using (at least) just one process, if not one thread,
> to do all I/O

Easier, depends. MS Access is trivially easy to use (for simple databases).

>
> Even then things get tricky.
> Consider you have placed an item on your 'basket' on a shipping app, on
> the basies that there are 2 in stock, go make a cup of coffeee, come
> back and try to checkout to find there are now none.
>
>
>

--
Cheers, Carlos.

Re: Contents of file changed while application is reading it

<tthvvq$27bbi$26@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11773&group=comp.os.linux.misc#11773

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: tnp@invalid.invalid (The Natural Philosopher)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Mon, 27 Feb 2023 10:17:30 +0000
Organization: A little, after lunch
Lines: 57
Message-ID: <tthvvq$27bbi$26@dont-email.me>
References: <ttg9pl$301qu$1@dont-email.me>
<DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
<ttgq6m$279gm$25@dont-email.me> <op.10zzw9sea3w0dxdave@hodgins.homeip.net>
<t2aucjxrkf.ln2@Telcontar.valinor> <tthv4d$27bbi$22@dont-email.me>
<vacucjxlnh.ln2@Telcontar.valinor>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 27 Feb 2023 10:17:30 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="4655b826320e8b98b9b7b1a215967df9";
logging-data="2338162"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+LdskjZ4Ae9j9hrE285snbRka0BgHZJ2Y="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Cancel-Lock: sha1:TJqnN2ZPnHvr5yzh61TWCyglLAM=
In-Reply-To: <vacucjxlnh.ln2@Telcontar.valinor>
Content-Language: en-GB
 by: The Natural Philosop - Mon, 27 Feb 2023 10:17 UTC

On 27/02/2023 10:13, Carlos E.R. wrote:
> On 2023-02-27 11:02, The Natural Philosopher wrote:
>> On 27/02/2023 09:34, Carlos E.R. wrote:
>>> On 2023-02-27 01:06, David W. Hodgins wrote:
>>>> On Sun, 26 Feb 2023 18:32:38 -0500, The Natural Philosopher
>>>> <tnp@invalid.invalid> wrote:
>>>>> I am pretty sure generally NO.
>>>>> Otherwise databases would have a hard time working
>>>>
>>>> Data base applications work by having one thread that does the
>>>> physical i/o for each file that contains the database. Multiple
>>>> applications can use the database, but they don't do the i/o to the
>>>> disk.
>>>
>>> Not all database applications work that way.
>>>
>>> For example, in MsDOS an application could lock for write a section
>>> of a file, write that, then remove the lock. Another application
>>> could be reading the same file, even writing in another section.
>>>
>>> This functionality was an add on: you needed to run the optional
>>> share.exe. But Windows had it natively.
>>>
>>> I believe Microsoft Access works like that.
>>>
>>>
>>> I am not sure this behaviour can be done in Linux. Long ago it could
>>> not.
>>>
>> File lockining always existed at the level of IIRC whole files.
>> But obliviously it is far far easier to have a databse engine
>> accepting all requests and using (at least) just one process, if not
>> one thread, to do all I/O
>
> Easier, depends. MS Access is trivially easy to use (for simple databases).
>
You call that a database? I dont. Any more than SqlLite is a
database...both are single user/process access only.

>>
>> Even then things get tricky.
>> Consider you have placed an item on your 'basket' on a shipping app,
>> on the basies that there are 2 in stock, go make a cup of coffeee,
>> come back and try to checkout to find there are now none.
>>
>>
>>
>

--
I would rather have questions that cannot be answered...
....than to have answers that cannot be questioned

Richard Feynman

Re: Contents of file changed while application is reading it

<tgcucjxlnh.ln2@Telcontar.valinor>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11774&group=comp.os.linux.misc#11774

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: robin_listas@es.invalid (Carlos E.R.)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Mon, 27 Feb 2023 11:16:29 +0100
Lines: 22
Message-ID: <tgcucjxlnh.ln2@Telcontar.valinor>
References: <ttg9pl$301qu$1@dont-email.me>
<DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
<ttgq6m$279gm$25@dont-email.me> <op.10zzw9sea3w0dxdave@hodgins.homeip.net>
<ttgtcg$279gm$36@dont-email.me> <wwv8rgjscnf.fsf@LkoBDZeT.terraraq.uk>
<tthusr$27bbi$21@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net lXMSfGoMMS1ldTftlPxEjgm5QTQyUPESjbv9FMUL6h9T1wpn0S
X-Orig-Path: Telcontar.valinor!not-for-mail
Cancel-Lock: sha1:p6VKtB+OA2BuT1cz6DL3BVT/LHA=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Content-Language: es-ES, en-CA
In-Reply-To: <tthusr$27bbi$21@dont-email.me>
 by: Carlos E.R. - Mon, 27 Feb 2023 10:16 UTC

On 2023-02-27 10:58, The Natural Philosopher wrote:
> On 27/02/2023 09:03, Richard Kettlewell wrote:
>> The Natural Philosopher <tnp@invalid.invalid> writes:
>>> IIRC a C style fread() or fwrite() goes straight to the OS and so
>>> there is no in program caching below that level, only OS disk caching
>>> which is invisible to the application
>>
>> You are thinking of read() and write() here - fread() & fwrite() will
>> use the process’s own buffer (unless you deliberately made the file
>> unbuffered).
>>
> Well yes and no, I was not aware that processes had their own buffers
> *below* fread/fwrite level.

I don't remember that much detail in C, but in Pascal (Borland variety,
possibly Lazarus too) each file gets (got) a buffer of a hundred
something buffer by default, inside the application.

--
Cheers, Carlos.

Re: Contents of file changed while application is reading it

<wwvcz5v878y.fsf@LkoBDZeT.terraraq.uk>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11775&group=comp.os.linux.misc#11775

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!nntp.terraraq.uk!.POSTED.tunnel.sfere.anjou.terraraq.org.uk!not-for-mail
From: invalid@invalid.invalid (Richard Kettlewell)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Mon, 27 Feb 2023 15:20:45 +0000
Organization: terraraq NNTP server
Message-ID: <wwvcz5v878y.fsf@LkoBDZeT.terraraq.uk>
References: <ttg9pl$301qu$1@dont-email.me>
<DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
<ttgq6m$279gm$25@dont-email.me>
<op.10zzw9sea3w0dxdave@hodgins.homeip.net>
<ttgtcg$279gm$36@dont-email.me> <wwv8rgjscnf.fsf@LkoBDZeT.terraraq.uk>
<tthusr$27bbi$21@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: innmantic.terraraq.uk; posting-host="tunnel.sfere.anjou.terraraq.org.uk:172.17.207.6";
logging-data="14199"; mail-complaints-to="usenet@innmantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:ONHQhQIPS7pIFEEhKMiqaeEi6DA=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
+r0NzP?vnz:e/knOY)PI-
X-Boydie: NO
 by: Richard Kettlewell - Mon, 27 Feb 2023 15:20 UTC

The Natural Philosopher <tnp@invalid.invalid> writes:
> On 27/02/2023 09:03, Richard Kettlewell wrote:
>> The Natural Philosopher <tnp@invalid.invalid> writes:
>>> IIRC a C style fread() or fwrite() goes straight to the OS and so
>>> there is no in program caching below that level, only OS disk caching
>>> which is invisible to the application
>> You are thinking of read() and write() here - fread() & fwrite() will
>> use the process’s own buffer (unless you deliberately made the file
>> unbuffered).
>>
> Well yes and no, I was not aware that processes had their own buffers
> *below* fread/fwrite level.

All of fread(), fgetc(), fscanf(), fgets() &c read from an in-process
buffer refilled with read() when empty. Similarly all of fwrite(),
fputc(), fprintf(), fputs() &c write to an in-process buffer which is
flushed with write() when full (or in some cases, when a newline is
written).

Nuances to this include:
* You can change the in-process buffering policy with setvbuf.
* A reasonable implementation choice is for large reads and writes to
bypass the in-process buffer, as an optimization.

read() and write() are the kernel syscalls which transfer data from/to
the buffer cache (or from/to a pipe or socket’s internal buffer, &c).

--
https://www.greenend.org.uk/rjk/

Re: Contents of file changed while application is reading it

<op.101b3taba3w0dxdave@hodgins.homeip.net>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=11776&group=comp.os.linux.misc#11776

  copy link   Newsgroups: comp.os.linux.misc
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: dwhodgins@nomail.afraid.org (David W. Hodgins)
Newsgroups: comp.os.linux.misc
Subject: Re: Contents of file changed while application is reading it
Date: Mon, 27 Feb 2023 12:27:19 -0500
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <op.101b3taba3w0dxdave@hodgins.homeip.net>
References: <ttg9pl$301qu$1@dont-email.me>
<DKqdnUe7v8BlT2b-nZ2dnZfqn_qdnZ2d@giganews.com>
<ttgq6m$279gm$25@dont-email.me> <op.10zzw9sea3w0dxdave@hodgins.homeip.net>
<t2aucjxrkf.ln2@Telcontar.valinor> <tthv4d$27bbi$22@dont-email.me>
<vacucjxlnh.ln2@Telcontar.valinor> <tthvvq$27bbi$26@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8bit
Injection-Info: reader01.eternal-september.org; posting-host="51f39f4b271dce7fd0755dd894f3bfa4";
logging-data="3492138"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+XmPsg8FzFkA6+CLUG4W7hE2+nbsMfKdI="
User-Agent: Opera Mail/12.16 (Linux)
Cancel-Lock: sha1:OUfZph/DaiR0BE5Y6jJ/2gG/+9E=
 by: David W. Hodgins - Mon, 27 Feb 2023 17:27 UTC

On Mon, 27 Feb 2023 05:17:30 -0500, The Natural Philosopher <tnp@invalid.invalid> wrote:
> On 27/02/2023 10:13, Carlos E.R. wrote:
>> Easier, depends. MS Access is trivially easy to use (for simple databases).
> You call that a database? I dont. Any more than SqlLite is a
> database...both are single user/process access only.

Database design does not consider the physical storage method. Once the data
requirements have been fully normalized
https://en.wikipedia.org/wiki/Database_normalization
it may need some level of denormalization for performance.

It doesn't matter whether it's stored in IMS DB, DB2, sqlite, spreadsheets, or flat
files. Any data that uses tables is logically a database, and the same design rules
apply, whether it's done formally or not.

Regards, Dave Hodgins

Pages:1234
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor