Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include #include #include /* Simple example of using gnu readline to get lines of input from a user. Needs to be linked with

#include #include #include #include #include /* Simple example of using gnu readline to get lines of input from a user. Needs to be linked with -lreadline -lcurses add_history tells the readline library to add the line to it's internal history, so that using up-arrow (or ^p) will allows the user to see/edit previous lines. */ int main(int argc, char **argv) { char *s; while (s=readline("prompt> ")) { add_history(s); /* adds the line to the readline history buffer */ free(s); /* clean up! */ } return(0); }

Task 5: Pipelined Instructions Your shell must support pipelined instructions - this means that each command line could include a number of external commands. Note that you do not need to support pipes with internal commands. For each pipe in the command line you need to take care of connecting stdout of the left command to stdin of the command following the "|". For example, if the user types "ls -al | sort", you need to arrange things so that the ls command is run with stdout directed to a Unix pipe, and that the sort command is run with stdin coming from that same pipe. A pipe is basically a buffer held by the kernel, having two file descriptors, one for reading and one for writing. The pipe maintains the order of the bytes, so that the first byte written to the pipe is the first byte read from the pipe. The pipe system call creates a pipe and generates two file descriptors. In order to create a pipe between two commands, your shell will need to create a pipe and then fork a child process for each command. In one process, you will redirect from stdout into the writing end of the pipe and in the other you will redirect from stdin to the reading end of the pipe. For this assignment, you will be required to pipeline two commands together. Pipelining and redirection should work together. For example, you should support ls -al| sort > output.txt.

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

Build It For The Real World A Database Workbook

Authors: Wilson, Susan, Hoferek, Mary J.

1st Edition

0073197599, 9780073197593

More Books

Students also viewed these Databases questions