Creating c program for linux


Build up a C program for Linux called pipes.c that does the subsequent:

In the main() function, it creates a pipe using the pipe() function, then generates two child processes with fork(). Child 1 redirects stdout to the write end of the pipe and then executes with execlp() the "ls -al" command. Child 2 redirects its input from stdin to read end of the pipe, then it executes the "sort -n -k 5" command.

After making both children, the parent process waits for them to terminate before it can exit.

Note that you might have to generate Child 2 first, followed by Child 1.

The parent program does the similar thing as a shell that runs the command "ls -al | sort -r -n -k 5".

You should use the fork(), pipe(), dup2(), close(), execlp() attributes (or other exec() variation). You can edit your program with geditapplication, accessible from the command line. Or install emacs using command “sudo apt-get install emacs” and learn to use it.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Creating c program for linux
Reference No:- TGS01546

Expected delivery within 24 Hours