On Mon, 3 Nov 2003 11:32:34 +0200, corneliu wrote
> > 3.
> > Cum se pot crea in C pt linux 2 procese paralele..?
> fork(); :)
> da de accord...
> switch(g=fork())
> {
> Case 0:
> default:
> 
> }
> Wait(pid,NULL);
> Face un proce/.///
> Dar cum apara si al doilea
> 
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 exe-
       cution.  On failure, a -1 will be returned in the parent's context,  no
       child process will be created, and errno will be set appropriately.

so:
 pid = fork();
 if (pid==0) 
 {
    // sunt in procesul 'copil'
    // faci ce vrei in al doilea proces...
 }
 else  
 {
    // sunt in procesul 'parinte'
    // faci ce vrei in procesul original
    // ---aici mai poti verifica si daca "pid" e "-1", adica eroare..
 };

http://webmail.easynet.ro - E-mail gratuit
Webmail, calendar pop3+smtp, 10MB Inbox + 20MB Folders


--- 
Detalii despre listele noastre de mail: http://www.lug.ro/


Raspunde prin e-mail lui