PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.cplus > Forking !
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Forking !

Réponse
 
LinkBack Outils de la discussion
Vieux 17/01/2008, 10h04   #1
harishashim@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Forking !

I sure hope this question is relevent to comp.lang.c++ . I have my
doubt but here I go!

I have very code that do as follows


pid_t pId = fork();

//Very large body of code
codeline1();
codeline2();
codeline3();
//etc etc etc

if (pId == 0) {

//child codes

}else if (pId < 0 ) {

//some error codes

}else {

//parent codes

}

My question is codeline1(), codeline2() and codeline3(). Are they
executed by the parent children or both?

Any comments?

Thanks In Advance!
  Réponse avec citation
Vieux 17/01/2008, 10h43   #2
Michael DOUBEZ
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Forking !

harishashim@gmail.com a écrit :
> I sure hope this question is relevent to comp.lang.c++ . I have my
> doubt but here I go!


It isn't. fork() is POSIX specific.

>
> I have very code that do as follows
>
>
> pid_t pId = fork();
>
> //Very large body of code
> codeline1();
> codeline2();
> codeline3();
> //etc etc etc
>
> if (pId == 0) {
>
> //child codes
>
> }else if (pId < 0 ) {
>
> //some error codes
>
> }else {
>
> //parent codes
>
> }
>
> My question is codeline1(), codeline2() and codeline3(). Are they
> executed by the parent children or both?


Both.

>
> Any comments?


I find it strange that you check for the error case so late (usually a
memory matter, so it is rather important) and I would also question the
interest of having instructions execution duplicated in the fater and
the child when you don't know if it successful or in with process you are.

Michael
  Réponse avec citation
Vieux 17/01/2008, 10h51   #3
harishashim@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Forking !


> > Any comments?

>
> I find it strange that you check for the error case so late (usually a
> memory matter, so it is rather important) and I would also question the
> interest of having instructions execution duplicated in the fater and
> the child when you don't know if it successful or in with process you are.
>
> Michael


Thanks for the reply. I am maintaining old codes.

If it is executed by both than I have a reason to cry foul and point
out that it is a bug.

Thanks again!
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h28.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11477 seconds with 11 queries