Mail Archives: djgpp/1997/04/14/06:38:17
Eli Zaretskii wrote:
>I don't understand. This is exactly what `spawnXX' function do right
>now. If you are willing to suspend the parent until the child exits,
>why do you need `fork' at all?
'spawnxx' runs a different program, 'fork' runs a thread in the same
program (well, sort-of). Take the following code:
main()
{
if (fork())
{
printf("Hello ");
}
else
{
printf("World!");
}
}
The bit which prints "Hello" is the child, but it isn't a separate
program it's part of the same one. I don't mind whether the child
finishes before the parent continues (which it might even in a true
multitasking environment), I do want it to run in the same program
as the parent.
(OK, on a real multiitasking system the data spaces would be separate,
but the code spaces still wouldn't be).
In tcsh, for example, the 'child' part of the fork /may/ do an exec
to run another program, in which case it could be replaced by spawn,
but it may not, it could do an internal function as the action.
The misunderstanding, I suspect, is because I was using the term 'child'
in the Unix sense and you read it in the DOS one. Or Maybe Not.
Chris
- Raw text -