LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Help using popen and execl (https://www.linuxquestions.org/questions/linux-software-2/help-using-popen-and-execl-532871/)

cdog 02-27-2007 07:25 AM

Help using popen and execl
 
Hi guys.
I have to write a program for a school project and I managed to finish it but it has an annoying bug:
One of the tasks is: the father process should gather all the files with the extensions .a and .b and the child process should sort the content of the files .a and store the sorted text back to the file and to search for a certain word in the files .b and save only those lines back to the file. I use popen for the father/child distribution (on the left side of the pipe is the father gathering the file names and on the right is the child). My problem: for the sort command I use "sort > tempfile" and after that I use fork and execl to move the tempfile to the original file. For a single file it works great, but if there are more files I get "mv" errors like cannot access or cannot unlink.
Any ideas? Thanks.

wjevans_7d1@yahoo.co 02-27-2007 09:13 AM

If you have several of these children going at once, do they all use the same temporary file name?

cdog 02-28-2007 03:31 AM

I only have 1 child that uses this temp file. and what's more strange is that is works fine if I open the temp file and copy the text to the original file.

wjevans_7d1@yahoo.co 02-28-2007 06:44 PM

Ok, could you back up and give the overall description of what process does what, and how many processes can exist for each chore?


All times are GMT -5. The time now is 07:23 PM.