Mail Archives: djgpp/2004/05/21/13:16:03
"Eli Zaretskii" <eliz AT gnu DOT org> wrote in message news:<9743-Thu20May2004201223+0300-eliz AT gnu DOT org>...
> > From: 048321887-0001 AT t-online DOT de (Udo Kuhnt)
> > Newsgroups: comp.os.msdos.djgpp
> > Date: 20 May 2004 06:40:00 -0700
> >
> > The documentation is not very detailed, but as I understand it, X_PCreate
> > creates a new process (or rather a new thread) in the same address room,
> > while Z_Dom_Fork copies the entire address room, which probably includes the
> > file handles of the calling process.
>
> Z_Dom_Fork is clearly documented to run the same program, but it
> creates a process in a separate VM, which is not very helpful for us,
> since there's no way to inherit file handles between VMs (otherwise we
> could have easily implemented `fork' on Windows by using the Windows
> `start' command). If our `fork' doesn't inherit file handles, the
> programs that use it will not work, as on Unix the child always
> inherits the parent's handles.
Well, I do not know anything about the start command you mentioned, but I
thought that if Z_Dom_Fork makes an exact copy of the first 4 MB of the
address room, then it would also copy the file handles. Anyway, I agree with
you that creating a new VM is probably not what we would want in this
context.
> It would be interesting to see what happens with this aspect of the
> process created by X_PCreate.
Since the child and parent process share the same VM, the file handles would
probably be the same for both processes. The child could share a data segment
with the parent, making it theoretically possible to pass the handles to it.
Now, how could one verify this? Perhaps by a test program that opens a file,
then creates a new process with X_PCreate. The processes would have to share
the parent's process and file handle. The processes check whether they are
parent or child by comparing their process handle with the parent's, then the
child tries to read some data from the file using the parent's file handle.
If this succeeds, the X_PCreate function could be used to fork a new process
in DJGPP, right?
- Raw text -