Opening the can of worms again:
da Silva, Joe wrote:
>
> > From: Clarence Verge [SMTP:[EMAIL PROTECTED]]
> > Sent: Thursday, 22 February 2001 14:28
> >
> > 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).
I hate to drag this along further than necessary, but I quote here from
Ray Duncan "Advanced MSDOS" 1986, re: EXEC (4BH):
All files or devices of the parent that were opened using the Handle
extended file-management calls are duplicated in the newly created child
task; that is, the child inherits all the active handles of the parent task.
Any file operations on those handles by the child, such as seek or file I/O,
also affect the file pointers associated with the parents handles.
And from Terry Dettman "DOS Programmers Reference" 1993, re the same 4BH:
A child process spawned in this way inherits the parent process I/O files
unless the parent specifically specifies otherwise in the file-open call
(Function 3DH). Standard files remain open. If standard files were re-
directed for the parent , they remain re-directed for the child.
If the parent was producing standard output, and the USER had re-directed
that to a file, this re-direction is an operation directly under the care
of DOS *NOT* the application. So the application shouldn't close 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).
No, I felt that could be a consequence of closing of re-directed files.
I now take a different position:
Maybe DOS is better than even *I* thought. The child gets a DUPLICATE handle.
A file handle duplicated by 45H can be closed by 3EH LEAVING THE ORIGINAL
OPEN for further read-write operations. <G> (Ray Duncan)
This can may now be safely closed. <G>
- Clarence Verge
--
- Help stamp out FATWARE. As a start visit: http://home.arachne.cz/
--