Mail Archives: djgpp-workers/1998/03/09/05:47:34
On Mon, 9 Mar 1998, Vik Heyndrickx wrote:
> DOS has a function that creates a temporary file, why cannot we use that
> for tmpfile?
Because it is not flexible enough: you cannot open the temporary file
with DENY_ALL sharing property, and you cannot control the name DOS
creates (it's not needed for `tmpfile', but *is* needed for `mkstemp')
and the place where DOS puts it (we want it to go to $TMPDIR, for
example).
> tmpfile is one aspect, the other functions that require a name to be
> returned instead of a file descriptor (handle) still have to cope with
> this kind of problems.
This problem always exists, AFAIK you can't do anything about it unless
you actually open the file when you create the name (and leak file
handles).
> My idea is to provide a name for those functions based upon at least:
> - a process ID (preferably r/m PSP address) 2^16
Won't all first-level programs in different DOS boxes on Windows have the
same PSP address?
> This resolution is enough to assert that:
> - no same filenames are produced by different processes
Not if the PSP problem above exists. You would need the VM id to cover
for this.
> - no same filenames are produced in one day
What would stop two programs to start on the same second in two different
DOS boxes? E.g., imagine two Make's running in two different DOS boxes:
they can easily launch GCC with less than 1 sec between them (on a fast
machine).
> Another problem, what should MAX_TEMPNAM (I'm not sure about this name,
> but you should know what I mean) in one of the header files be like? The
> value of X?
AFAIK, this is the max number of unique names we can *potentially*
generate.
- Raw text -