www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/15/15:50:50

From: "Weiqi Gao" <weiqigao AT crl DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: fork????
Date: 15 Dec 1996 16:48:59 GMT
Organization: CRL Dialup Internet Access
Lines: 25
Message-ID: <01bbeaa7$bc5efb80$0f0171a5@weiqigao>
References: <32B21822 DOT 4F80 AT novia DOT net>
NNTP-Posting-Host: crl2.crl.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019