Mail Archives: djgpp-workers/1999/02/28/12:34:09
Bonjour
> `spawn' *does* allow to redirect the standard handles of the child
> program, it just requires that the parent redirects its handles for
> that; the child then inherits those redirected handles. Since the
> parent doesn't resume until the child exits, it doesn't need to worry
> about its standard handles during the time the child program runs.
> When the child does return, the parent simply restores its handles to
> previous values.
>
Ho ! I see, clever.
> > However it is possible to do it on Windows but not with djgpp framework ?
>
> Since the multitasking is provided by Windows (which *can* be called
> an operating systerm ;-), it is exactly like on Unix, except that the
> way I described to run programs asynchronously doesn't include
> inheritance of standard handles and environment variables, so these
> must be treated separately and specially (in this case only).
You've said that "start /m" will actually "fork" a process,
How about something like this, for windows, will that work ?
Note this is just pseudo-code. There is lot of race conditions, i.e signals
etc ...
inet_spawn (const char path, int fdmap[], int fdlen)
{
int fd[3];
int pid;
/* save/redirect std */
fd[0] = dup(FILENO_STDIN);
fd[1] = dup(FILENO_STDOUT);
fd[2] = dup(FILENO_STDERR);
dup2(fdmap[0], FILENO_STDIN);
dup2(fdmap[1], FILENO_STDOUT);
dup2(fdmap[2], FILENO_STDERR);
pid = spwan(P_NOWAIT, "start", "/m", path, NULL);
/* bring std back */
dup2(fd[0], FILENO_STDIN);
dup2(fd[1], FILENO_STDOUT);
dup2(fd[2], FILENO_STDERR);
return pid;
}
--
au revoir, alain
----
Aussi haut que l'on soit assis, on est toujours assis que sur son cul !!!
- Raw text -