LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-27-2007, 07:25 AM   #1
cdog
Member
 
Registered: Dec 2005
Posts: 65

Rep: Reputation: 15
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.
 
Old 02-27-2007, 09:13 AM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
If you have several of these children going at once, do they all use the same temporary file name?
 
Old 02-28-2007, 03:31 AM   #3
cdog
Member
 
Registered: Dec 2005
Posts: 65

Original Poster
Rep: Reputation: 15
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.
 
Old 02-28-2007, 06:44 PM   #4
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
popen for windows csfalcon Programming 6 11-30-2005 08:21 AM
popen output not appear dimsh Programming 4 10-22-2005 02:56 AM
where do i get a bidirectional popen pipe? Thinking Programming 9 10-21-2005 07:42 AM
Help needed with system() and popen! twirl Programming 4 09-14-2005 09:22 AM
C Popen gold5angel Programming 2 04-17-2004 07:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration