ContainerDriver
27-06-2003, 10:45
Hallo,
ich habe ein kleines Problem mit fork().
Hier ist ein Ausschnitt aus dem Prog:
//----------------------------------
pid_t one=getpid();
pid_t two=fork();
pid_t three=0;
if (getpid()==one) //dieser Aufruf funktioniert
{
three=fork();
cout << "1: Hallo" << endl;
}
if (getpid()==two) //erscheint _nicht_
{
cout << "2: Hallo" << endl;
}
if (getpid()==three) //erscheint
{
cout << "3: Hallo" << endl;
}
//-----------------------------------
Also, ich will 3 Prozesse haben, jeder soll "Hallo" ausgeben. 1 und 3 geben es aus, 2 nicht. Warum nicht?
Vielen Dank für die Antwort
MFG Florian
ich habe ein kleines Problem mit fork().
Hier ist ein Ausschnitt aus dem Prog:
//----------------------------------
pid_t one=getpid();
pid_t two=fork();
pid_t three=0;
if (getpid()==one) //dieser Aufruf funktioniert
{
three=fork();
cout << "1: Hallo" << endl;
}
if (getpid()==two) //erscheint _nicht_
{
cout << "2: Hallo" << endl;
}
if (getpid()==three) //erscheint
{
cout << "3: Hallo" << endl;
}
//-----------------------------------
Also, ich will 3 Prozesse haben, jeder soll "Hallo" ausgeben. 1 und 3 geben es aus, 2 nicht. Warum nicht?
Vielen Dank für die Antwort
MFG Florian