Send input to child process
I have a linux school assignment. I have to write a program in C that scans a directory and sends all the files with certain extentions to the child process that does all the job. I managed to open and read the directory using the functions opendir and readdir, but I don't know how to send them to the child. I need some ideas.
|
Type the following command:
man socketpair Then experiment with it and have fun! Your class sounds great! |
just to get you started
Code:
int pipe_file_descriptors[2]; convert the read end into a FILE object read from it if im in the parent close the read end of the pipe blah blah same thing but backwards |
Is there a way to use popen because I know this command? Also, on files with specific extensions the child process should run different functions. How am I going to do this? Thanks?
|
when you use popen the child process is a shell command so thats not what you want at all.
as far as extensions -- (not something usually done in Linux) you just look at the filename string and decide if it has the extension you are looking for. we shouldn't give you more yet so you can try yourself. you post code later if you get stuck and we can help a little more. if we give it to you you won't learn. programming is all about knowing you can figure it out. not many of us know ahead of time how to do stuff til we are in the middle of it and figure it out. |
see man pages for
pipe, fork, and if you want to dup and dup2 also, Manish YM |
All times are GMT -5. The time now is 05:41 AM. |