I understand the fork concept. I'm trying to solve the following problem.
I have to write a program that forks. The parent process gets a valid Unix command from the user, and passes it to the child. The child executes the given command, returning the results to the parent, which displays them.
explain any example of the program?
./a.out ls
parent : get command name - ls
child : execute that command not display
parent : display the command result
file1 file2 file3
(Or) (If you are not understand)
Design this architecture
parent
INPUT
DISPLAY
-----------
CHILD
PROCESS EXECUTE -------------
Where
INPUT - Get the input from the user which could be a valid unix command
EXECUTE - Execute the given command
DISPLAY - Display the result of the command.
fork()
is void? It returns the PID of the child to the parent, and 0 to the child. – alexis Feb 2 at 12:37