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!
.
|
|
| User: "Michael DOUBEZ" |
|
| Title: Re: Forking ! |
17 Jan 2008 04:43:44 AM |
|
|
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
.
|
|
|
| User: "" |
|
| Title: Re: Forking ! |
17 Jan 2008 04:51:40 AM |
|
|
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!
.
|
|
|
|
|

|
Related Articles |
|
|