creating Multi-process !!!!

i have a program that will create a father process( called 1 ) then the program asks if u want to add processes suppose that we want to add a process (1.1 et 1.2 ) if we want to add a process how can i specifie if its 1.1.1 or 1.2.1 !!!!
Ask the user !!!!
OMG R0mai epic ansr !!!1!11!!!one
@OP: if R0mai's amazing answer was insufficient why don't you start by showing us some code?
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

int main (int argc, char *argv[])
{
int choix=0;
bool fonctionnel=false;
while(fonctionnel)
cout<<"1) Afficher arborenscence"<<endl;
cout<<"2) Ajouter processus"<<endl;
cout<<"3) Arrêter processus"<<endl;
cout<<"4) Récuperer état de processus"<<endl;
cout<<"5) Terminer"<<endl;

cin>>choix;

switch(choix)
{
case 1 :
pid_t pid = fork();
if(pid==0)
{
printf("processus fils"
}

case 2 :

case 3 :

case 4 :

case 5 : fonctionnel = true;

default : cout<<"Veuillez entrer un autre numero entre 1 et 5"<<endl;
cin>>choix;
}

}
return EXIT_SUCCESS;
}
that the code to start with !!!
Can you even compile it ???? I doubt it !!!!
Please post a compilable code and translate your identifiers and strings to English.
Next time use [code][/code] tags.
Last edited on
i have a program that will create a father process

What? How would a process create it's own parent process?
That's like saying an egg could lay a chicken.
I'm pretty good with my french. Let's see:
Veuillez entrer un autre numero entre 1 et 5
I believe that's along the lines of: enter another number between 1 and 5
The first few cout lines are:
#1 Unknown
2 Add process(es)
3 Stop process(es)
4 Restore state of processes? (not quite sure)
5 Exit
choix = choice. fonctionnel = functional AFAIK.
And I did not use a translator program for that.
Anyway, I think that code might compile. Just that it's really hard to tell with no code tags or indentation.
And, @OP: I don't see any actual creating of processes here. Do you actually know how to create a process?
Last edited on
Anyway, I think that code might compile.

He is missing the closing parenthesis of the printf call*, and has one unnecessary closing bracket.
*(Why he uses cout and printf together for simple string output is another mystery)

I don't see any actual creating of processes here.

I've never used it but doesn't fork() do something like that?
Last edited on
no this programs doesnot compile : but i am gonna explain for u wut i tried to do :

first create a process (1) this process 1 ask the user ( ANYONE ) to choose an option from the menu :

- add a process
-stop a process
-show the status of a processus
-terminate every thing and stop the program



i have to create 5 generations of processes ( 1 , 1.1 - 1.2 , 1.1.1- 1.2.1 - 1.2.2 .... )
thats wut i am tryin to do with my beginners code so any suggestion ?
Create some strings to store the name of the processes. Each time you create a new process, create a new string to accompany it. Take the name of the parent and append whatever it is you want to end it with. (.1, .2, etc)
Or you could write a class to contain this information in a process tree package.
i have to ceate a file id.txt to store this pids! but some more explanation coz i am a beginner and i am not that good in processes things !
OK, that crap English is really getting to me. I've been told that I'm being a little harsh (and those of you who did, you are probably right), and I'm honestly trying to tone down, but do stick to proper grammar and spelling. And those exclamation marks are unnecessary. It's like typing in all caps. This isn't life and death, it's just programming.
Now then, here's what I was talking about. You start out with a process named 1. You create a string that represents that name. The string's contents are "1". (PID, or whatever you want to call it.)
When you create a child of that process, you take the string id of the parent (which currently equals 1) and then append a period, and the number of the child. So if you were creating child 2 of process 7, it would look like this:
childPID = parentPID + "." + PIDnumber
Assuming all those variables are strings. (PIDnumber might be an integer and it would still work of course.)
Once you create that PID, you output it to a file. If you know how to handle files good. If not check the documentation in this website. The tutorial therein has an explanation for STL file manipulation.
Got all that?
Last edited on
i think so i am gonna try to write some code to begin . and sure i will have more questions .
Tummy I totally agree with you, I hate it when kids (or even adults) get on here speaking in l33t, or usin masiff abrev8ns!!1!
But I think there's a big difference between that and someone who doesn't speak English as their primary language. French Canadian, or French most speak(write) French better than English.

I'm pretty good with my french. Let's see:


If this was a French site, you would have butchered it majorly :)
Last edited on
I know. After all, French isn't my first language. But I know enough to translate. After all, this is an English site.
You have a point:
u wut i
suggests sound knowledge but lack of implementation.
lmao, this thread is funny

& post in code brackets!!!!!!!

Last edited on
Topic archived. No new replies allowed.