|
-
February 10th, 2007, 06:55 PM
#1
Forking Processes Help!
Need a start on how to tackle this, thanks in advance!
Write a simple shell-like program that reads user commands and executes them using a combination of "fork", "exec", and "pipe".
history | head -10 | tail -5
Print the 6th through the 10th history commands. Your shell will have to set up a loop to create three processes and link them together using pipes so that the first child process runs "history" (and writes its output to a pipe), the second child process run "head" (with argument "-10"), reads from its standard input (which is the pipe into which the first child process writes) and writes to a pipe from which the third child process that runs "tail", reads. "tail" writes its output to the standard output.
The program has to take into account Pipes | and input and output redirection <, >. There are presumably no wrong inputs. i.e. the commands are all linux commands. Also the pipes are not finite meaning that input can be any number of pipes or redirections
Any advice would be greatly appreciated!
Last edited by RickRoss; February 10th, 2007 at 06:58 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|