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.
|