ECE 3600 - Assignment P05 - Due: 17 Sept. 2022


./pipe cmd1 cmd2

Write a C program that creates two children, and connects the standard output of one to the standard input of the other using a pipe.

The child commands to run are specified on the command line.

Use pipe(), fork(), dup2(), close(), execlp(), and wait() system calls.

The parent process should wait for both children to complete (i.e. wait(0); wait(0);) before exiting.

Sample runs:

  $ make
  gcc -Wall -o pipe pipe.c
  $ ls
  Makefile  pipe  pipe.c
  $ ls | cat
  Makefile
  pipe
  pipe.c
  $ ls | wc
        3       3      21
  $ ./pipe ls wc
        3       3      21
  $ ./pipe date cat
  Fri Sep  2 08:10:57 EDT 2022
  $ ./pipe date rev
  2202 TDE 20:11:80 2  peS irF
  $
Reference code:   pipe() example;   fork() and execvp() example;   pipe() and execlp() example (from w3 notes from class)
Upload source files - individual files or archive (e.g. zip, tar)

Programs must compile with no warnings or errors using: gcc -Wall

Each source file must start with a comment containing your name and a description.