www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/02/15/08:51:45

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: reading a currently writting file
Date: 15 Feb 2001 13:34:52 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 34
Message-ID: <96glts$mn5$1@nets3.rz.RWTH-Aachen.DE>
References: <3a8bc878 AT filemon DOT telecable DOT es>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
Mime-Version: 1.0
X-Trace: nets3.rz.RWTH-Aachen.DE 982244092 23269 137.226.32.75 (15 Feb 2001 13:34:52 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 15 Feb 2001 13:34:52 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Rafael García" <rafael AT geninfor DOT com> wrote:
> I have a program that write some information about its work in a LOG file.
> When it ends execution I can open it to know what was happening.

> But it would be nice if I could read it meanwhile running. If I try to open
> the file for reading from another Windows DOS box, fopen() fails.

The fundamental problem is that DOS, by its very nature, is not a
multitasking operating system, i.e. it does not expect more than a
single program to be running in the system, at any given time. Neither
does your typical plain vanilla DOS program.

Now, obviously, network file systems and multitaks add-ons (i.e.:
Windows) have been used with DOS for a long time, so how could they do
that?  They added a crutch to MSDOS to take care of the file access
sharing issues that arise, in these situations. That one was called
'share.exe', and it's the duty of every single DOS program, then, to
co-operate actively with 'share' in order to make the mose use of it.
(In Win9x, there is no manifest 'share.exe' TSR any more: its
functionality is now part of the automatically loaded IFSHLP.SYS
driver, IIRC).

> Is it possible to do?

AFAIK: yes. Look up the help on DJGPP's libc function 'open' to see
what additional mode bits to set to let other programs access your
files in readonly mode while you're still writing them. If you're
currently using <stdio.h> functions (i.e. fopen(), and FILE*
structures) to access files, you'll have to interface to the
<unistd.h> ones via fileno() and fdopen().

-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019