See below ...
Joe.
> -----Original Message-----
> From: Clarence Verge [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, 22 February 2001 14:28
> To: [EMAIL PROTECTED]
> Subject: Second thoughts on closing someone else's files
>
> This is turning into a real can of worms :(
>
> What if a TSR is loaded by an application via one of the EXEC functions ?
> Not unusual. Then it inherits the open files of the parent.
>
[da Silva, Joe]
No, it does NOT! The TSR is an independent application,
with it's own PSP (which is what DOS uses to determine
what application "owns" a file, in particular, what application
has the file open in Write or Read+Write mode ...). It does
not inherit any file from it's parent (just a copy of the parent's
environment, that's about it).
If you want to exec another application, to operate on
a file, you must close it first, THEN call your "child"
application, which *should* close the file before returning
(for normal applications, I think the DOS does this
automatically anyway, though it's knowledge of the PSP).
The "parent" application can then re-open the file, if it
has further need of it!
> If the TSR then closes the file handle of STDOUT before return to the
> parent, that parent may be speechless.
>
[da Silva, Joe]
Again, you seem to forget that this doesn't matter when
STDOUT is just the console device (character device),
but things can get muddled(!) when STDOUT has been
redirected to a file (block device).
> It seems a safer approach is for the TSR to keep hands off and let the
> parent close the file if that is what is desired.
>
[da Silva, Joe]
See Ralf Brown's interrupt list, re. Int $21, Function $31!!!
> But what if the parent is Command.com ? I just checked and neither
> DOS Int27 or Int21sub30 automaticaly closes files when the TSR returns
> to DOS.
>
[da Silva, Joe]
That's the whole problem! That's why the TSR must do
this itself!
> What if the launcher closes its STDOUT handle before loading the TSR ?
> Then it knows it has to open it again when the TSR is finished loading.
> But this defeats the ability of the application to re-direct STDOUT.
>
[da Silva, Joe]
Hmmm ... that's an interesting scenario, if sufficiently motivated,
I may check this out, just for curiosity. <g>
However, my initial reaction is that the redirection will only
occur for the parent application. When this invokes another
application that uses STDOUT, I think the child's output will
actually go to the console (not entirely sure, here).
> Anyway, I don't think you can close DOS's handle to STDOUT but I don't
> know for sure.
>
> I would like to close the can please. <g>
>
>
>
>
>
>
>
> - Clarence Verge
> - Still using Arachne V1.62 ....