| UNIX/Linux Forum Archives · Rules and Guidelines · Disclaimer |
Help
Search
Members
Calendar
|
| Welcome Guest ( Log In | Register ) | Resend Validation Email |
![]() ![]() ![]() |
| naifq2 |
|
|
Newbie ![]() Group: Members Posts: 1 Member No.: 722 Joined: 17-December 04 |
hi and good morning
i have a program that i wrote for unix shels and i want to modify it so it have more functionability only. i need this program to ask the user to INPUT any 2 arguments he wants and then it executes this arguments, the program should use pipes. here is my program that it should be modified, if it cannot be modified or difficult please help me to create a new program to do the same functions. int main(void) { int pfd[2]; int pid; if (pipe(pfd) == -1) { perror("pipe failed"); exit(1); } if ((pid = fork()) < 0) { perror("fork failed"); exit(2); } if (pid == 0) { close(pfd[1]); dup2(pfd[0], 0); close(pfd[0]); execlp("wc", "wc", (char *) 0); perror("wc failed"); exit(3); } else { close(pfd[0]); dup2(pfd[1], 1); close(pfd[1]); execlp("ls", "ls", (char *) 0); perror("ls failed"); exit(4); } exit(0); } |
![]() |
![]() ![]() ![]() |