Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Successful Keyword Searching Initiating Research On Popular Topics Using Electronic Databases

Authors: Randall MacDonald, Susan MacDonald

1st Edition

0313306761, 978-0313306761

More Books

Students also viewed these Databases questions

Question

Detailed note on the contributions of F.W.Taylor

Answered: 1 week ago

Question

explain the concept of strategy formulation

Answered: 1 week ago