Unix/Linux 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

Thread Tools Search this Thread Display Modes
Old Unix and Linux 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: Linux

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 Unix and Linux 11-19-2012
jim mcnamara jim mcnamara is offline Forum Staff  
Join Date: Feb 2004
Last Activity: 21 October 2017, 7:54 PM EDT
Location: NM
Posts: 11,215
Thanks: 567
Thanked 1,110 Times in 1,024 Posts
Please post this in the homework forum. Thank you.
Sponsored Links

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 11:40 AM
Question about wait guessingo Shell Programming and Scripting 2 11-19-2009 11:14 AM
Fork wait in background process - large delay vishnu.priya Red Hat 1 06-25-2009 10:05 PM
Fork wait in background process - large delay vishnu.priya Red Hat 0 06-23-2009 08: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 03:04 PM

All times are GMT -4. The time now is 08:54 PM.