Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify the program below to pass -l option to the ls command. /*Sample C program for Lab 3*/ #include #include #include #include //main int main()

Modify the program below to pass -l option to the ls command.

/*Sample C program for Lab 3*/ #include #include #include #include //main int main() { int fds[2]; pipe(fds); /*child 1 duplicates downstream into stdin */ if (fork() == 0) { dup2(fds[0], 0); close(fds[1]); execlp("more", "more", 0); } /*child 2 duplicates upstream into stdout */ else if (fork() == 0) { dup2(fds[1], 1); close(fds[0]); execlp("ls", "ls", 0); } else { /*parent closes both ends and wait for children*/ close(fds[0]); close(fds[1]); wait(0); wait(0); } return 0; }

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

Database Design And Implementation

Authors: Shouhong Wang, Hai Wang

1st Edition

1612330150, 978-1612330150

More Books

Students also viewed these Databases questions

Question

Is it clear what happens if an employee violates the policy?

Answered: 1 week ago