[ LUGOS ] fork

Metod Koželj metod.kozelj na rzs-hm.si
Pon Jun 29 10:42:04 CEST 1998


Howdy!

On Mon, 29 Jun 1998, Gasper Fele - Zorz wrote:

> Kako bi program sforkal tako, da bi se ga v childa prekopiral le del ?
> 
> V mislih imam nekaj takega kot 
> fork(){
> 
> } , pri cemer bi se del v {} izvedel kot otrok.

Preberi si man 2 fork. Tam ti pise:

RETURN VALUE
       On  success,  the  PID of the child process is returned in
       the parent's thread of execution, and a 0 is  returned  in
       the child's thread of execution.  On failure, a -1 will be
       returned in the parent's context, no child process will be
       created, and errno will be set appropriately.

Se pravi:

ret=fork();
if (ret==0) {
   child business
}
else {
   parent business
}


Peace!
  Mkx




Dodatne informacije o seznamu Starilist