Linux fork, execv, wait question
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
|linux process fork exec wait|
|Thread Tools||Search this Thread|
|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|