From: Simon Wright <simon@pushface.org>
Subject: Re: Exclusive file access
Date: Tue, 01 Sep 2015 16:13:14 +0100
Date: 2015-09-01T16:13:14+01:00 [thread overview]
Message-ID: <lyh9nexjed.fsf@pushface.org> (raw)
In-Reply-To: ed3129f2-7c95-4ad9-ba0a-a8c7e4bfe6ae@googlegroups.com
ahlan@marriott.org writes:
> Bruce B. tells me that there are routines in the package Directories
> that can be used to check if the file is already open. However that
> wouldn't be a full solution because there would be nothing to stop any
> other program from opening the file and messing with it. However it
> would be a start. If the file was already opened (by some other
> process) then I could avoid opening it. Unfortunately I couldn't find
> any such routine in Ada.Directories. Am I going blind?
GNAT.Directories perhaps? though I only see an Is_Open for directories,
not files.
GNAT.OS_Lib (a renaming of System.OS_Lib)? no, don't think so.
> So far the only solution I can see is for me to write my own filing
> system, one that has the ability to open the file for exclusive file
> access. However I cannot believe that this is what people really do.
> As it stands if I write a program that writes a log to a text file a
> second occurrence of the program if run concurrently will mess up this
> log.
> Is there really no way for an Gnat Ada program to open a file for
> exclusive access against other processes without resorting to the
> program writing his/her own filing system? (Open/Read/Write/Close that
> call directly the OS API)
I misunderstood you. To me, "filing system" means the whole organisation
of files with hierarchies of directories.
I think you are rather out of luck. I can see how it might be done on OS
X [open(2) with O_EXLOCK, then write(2)].
But, if you want a logger, what about for example Alog[1]? It's probably
overkill. But it's an exact analog of how you'd do it for tasking within
one process: open the file in a dedicated task, and send messages to be
logged to the task.
[1] http://www.codelabs.ch/alog/
next prev parent reply other threads:[~2015-09-01 15:13 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-27 13:52 Exclusive file access ahlan
2015-08-27 14:27 ` gautier_niouzes
2015-08-31 23:20 ` Randy Brukardt
2015-09-01 16:23 ` Pascal Obry
2015-09-01 20:48 ` Randy Brukardt
2015-08-27 14:42 ` Björn Lundin
2015-08-27 14:48 ` G.B.
2015-08-27 15:08 ` Björn Lundin
2015-08-27 18:38 ` tmoran
2015-08-27 23:16 ` Georg Bauhaus
2015-08-27 23:29 ` Pascal Obry
2015-08-28 7:25 ` Georg Bauhaus
2015-08-27 15:15 ` ahlan
2015-08-27 18:29 ` Jeffrey R. Carter
2015-08-28 5:41 ` ahlan
2015-08-28 7:10 ` Georg Bauhaus
2015-08-28 17:40 ` ahlan
2015-08-28 19:49 ` Anh Vo
2015-08-28 21:06 ` Simon Wright
2015-08-28 21:38 ` Jeffrey R. Carter
2015-08-29 7:05 ` Dmitry A. Kazakov
2015-08-29 8:31 ` Pascal Obry
2015-08-29 12:02 ` Dmitry A. Kazakov
2015-08-30 11:35 ` Florian Weimer
2015-08-30 12:44 ` Dmitry A. Kazakov
2015-08-30 19:37 ` Florian Weimer
2015-08-31 7:22 ` Dmitry A. Kazakov
2015-08-31 21:12 ` Florian Weimer
2015-09-01 7:26 ` Dmitry A. Kazakov
2015-09-07 18:27 ` Florian Weimer
2015-09-07 19:06 ` Dmitry A. Kazakov
2015-09-11 16:54 ` Florian Weimer
2015-08-31 23:34 ` Randy Brukardt
2015-09-01 7:33 ` Dmitry A. Kazakov
2015-08-29 16:07 ` gautier_niouzes
2015-08-29 17:12 ` Dmitry A. Kazakov
2015-09-01 12:37 ` brbarkstrom
2015-09-01 14:05 ` ahlan
2015-09-01 15:13 ` Simon Wright [this message]
2015-09-01 20:36 ` Randy Brukardt
2015-09-01 15:17 ` Jacob Sparre Andersen
2015-09-01 20:37 ` Randy Brukardt
2015-09-01 16:05 ` G.B.
2015-09-01 20:02 ` brbarkstrom
2015-09-01 21:17 ` Simon Wright
2015-09-05 15:52 ` Björn Lundin
2015-09-01 20:31 ` Randy Brukardt
2015-09-01 15:31 ` ahlan
2015-09-05 15:56 ` Björn Lundin
2015-09-06 17:38 ` brbarkstrom
2015-09-06 19:52 ` Björn Lundin
2015-09-07 15:18 ` brbarkstrom
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox