PLEASE, There is a lot of question like this, but they are all wrong... Please, do something about it! 1. Pipes (50 pts.

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

PLEASE, There is a lot of question like this, but they are all wrong... Please, do something about it! 1. Pipes (50 pts.

Post by answerhappygod »

PLEASE, There is a lot of question like this, but they are all
wrong... Please, do something about it!
1. Pipes (50 pts.) Write a C program for Linux called pipes.c
that does the following: In the main() function, it creates a pipe
using the pipe() function, then creates two child processes with
fork(). Child 1 redirects stdout to the write end of the pipe and
then executes with execlp() the "ps -aux" command. Child 2
redirects its input from stdin to the read end of the pipe, then it
executes the "sort -r - n -k 5" command. After creating both
children, the parent process waits for them to terminate before it
can exit. Note that you may have to create Child 2 first, followed
by Child 1. The parent program does the same thing as a shell that
runs the command "ps -aux | sort -r -n -k 5". You must use the
fork(), pipe(), dup2(), close(), execlp() functions.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply