Mail Archives: djgpp/1996/12/15/15:50:50
Dead_and_gone <alaric AT novia DOT net> wrote in article
<32B21822 DOT 4F80 AT novia DOT net>...
> does djgpp have a port of the fork function, I would code up a small test
> program but I have yet to figure out how to use fork ( I am mostly a dos
> programmer! )
Here's how you use fork():
int d;
i = fork();
printf("%d\n", i);
This will print two numbers: one is zero, by the child process, and the
other is the process id of the child process, printed by the parent
process. You usually treat i < 0 (fork() failed, no new processes); i = 0
(child) and i > 0 (parent) differently.
As for DJGPP, the documentation says:
This function always returns -1 and sets `errno' to ENOMEM, as MS-DOS does
not support multiple processes. It exists only to assist in porting Unix
programs.
--
Weiqi Gao
weiqigao AT crl DOT com
- Raw text -