Re: Forking Processes Help!
My advice is that you should make an effort yourself and post here if you have more specific question(s).
Re: Forking Processes Help!
Here are some reference examples :
FORK
Exec
PIPES
Good luck,
Gili
Re: Forking Processes Help!
Okay
I need to read in an input line something like
ls -l | sort - n -r | head
I have a struct to do this, something like:
struct getCommand
{
string command;
vector < string > args;
int numPipes;
};
So in my main() I will need to read the first string ("ls" in this example) and store it as a command string, then i need to store the arguments of that command (everything leading up to a '|' character) into a vector so I can call execvp on them later in the program. And then of course I need to parse to count the number of Pipes in the input.
The catch is, I need to loop this until '\n' reading any number of commands, args and pipes and I'm not sure on the syntax to do this exactly.
Thanks for help in advance
Re: Forking Processes Help!
Dear Mr. Ross,
I feel that you will find the following steps helpful:
1) in parent, pipe ur 2 element p1 and p2, close the write end of the p1[1]
2) fork
3) in child, dup2 ur p1 for reading and dup2 ur p2 for writing
4) execute ur command
5) close both ends of ur p1 and ur p2 in child then kill your child!
then..
6) in parent process, close ur p2 write
7) stick it up u face and shake it shake it!! u make me sick! learn how to code before you flex nuts. read a book or something.
Cordially yours,
Dr. Stff in u FACE
P.S. I am gay
Re: Forking Processes Help!
It's good to see more and more people programming for Linux and other operating systems besides M$ Windows.