Linux fork, execv, wait question | Unix Linux Forums | Programming

  Go Back    

Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Linux fork, execv, wait question


linux process fork exec wait

Closed Thread    
Thread Tools Search this Thread Display Modes
Old 11-19-2012
afulldevnull afulldevnull is offline
Registered User
Join Date: Sep 2012
Last Activity: 19 November 2012, 6:13 PM EST
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Linux fork, execv, wait question

Hi All,

I have a program for class that needs to do the following:
1. Print the directory entries from the current directory using ncurses
2. Provide a prompt next to each directory entry and allow the user to enter commands that may or may not be about the file
3. Execute those commands in sequence

My question is this:
How can I use fork, execv, and wait to allow for commands that also use ncurses or stdin/stdout to do what they need to do and then restore my ncurses program.


Say I want to execute "ls /etc/ | more". If I use system() the output is jumbled like this:

How do I make it so that when I press ENTER, the output of more is exactly as you would see it if you opened the terminal and typed it, and then after more terminates, my ncurses program reappears as if nothing happened.

It seems like if I were to use execv it would accomplish what I want because from the man pages: "The exec family of functions replaces the current process image with a new process image." If I were to replace a child process image with the process image of "more", it should achieve what I want correct? Can anyone please provide me with some insight?

Thanks for reading
Sponsored Links
Old 11-19-2012
jim mcnamara jim mcnamara is offline Forum Staff  
Join Date: Feb 2004
Last Activity: 1 March 2015, 9:19 AM EST
Location: NM
Posts: 10,389
Thanks: 322
Thanked 847 Times in 786 Posts
Please post this in the homework forum. Thank you.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Newbie question on exec,fork, wait,pipe C Cuervo Programming 1 06-06-2011 12:40 PM
Question about wait guessingo Shell Programming and Scripting 2 11-19-2009 12:14 PM
Fork wait in background process - large delay vishnu.priya Red Hat 1 06-25-2009 11:05 PM
Fork wait in background process - large delay vishnu.priya Red Hat 0 06-23-2009 09:24 AM
How can i use fork,sleep,wait and write in a process with father and son..?? gumlucin UNIX for Dummies Questions & Answers 3 10-29-2008 04:04 PM

All times are GMT -4. The time now is 12:36 PM.