Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a simple shell in C to support piping. Use dup2(and/or dup). 1. Your main function should read a single line from stdin that is
Write a simple shell in C to support piping. Use dup2(and/or dup). 1. Your main function should read a single line from stdin that is guaranteed to consist of words separated by a single space and with a pipe symbol (vertical bar "I") somewhere before the end. 2. Use fork such that the parent executes the command described by what comes before the pipe symbol and redirects it's stdout to the pipe input. The child process should execute the command following the pipe symbol and redirect the its stdin from the pipe output. (please add comments on the code lines, indicating this functionality). 3. For example, if the line was: Is WC-W The "Is" command output would be piped into the "wo" command ("word count") with option -W" (count only words not characters and lines). The result would be the number of files in the current directory Write a simple shell in C to support piping. Use dup2(and/or dup). 1. Your main function should read a single line from stdin that is guaranteed to consist of words separated by a single space and with a pipe symbol (vertical bar "I") somewhere before the end. 2. Use fork such that the parent executes the command described by what comes before the pipe symbol and redirects it's stdout to the pipe input. The child process should execute the command following the pipe symbol and redirect the its stdin from the pipe output. (please add comments on the code lines, indicating this functionality). 3. For example, if the line was: Is WC-W The "Is" command output would be piped into the "wo" command ("word count") with option -W" (count only words not characters and lines). The result would be the number of files in the current directory
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started