Description
Exercise #2
Create two C programs, listen.c and say.c that replicate the functionality
of the two bash scripts as closely as possible. Things you may need to know to
complete this assignment are:
- The system calls:
fork(2),execve(2)/execlp(3) andwait(2)/waitpid(2) to fork and exec the clear command. - The C library function
mkfifo(3) or the system callmknod(2) and system callunlink(2) to make the named pipe and later remove it. - The system call
chmod(2) to set the permissions on the fifo - The system calls
access(2) and/orstat(2) to test for the existence of the named pipe. (Theif [ -p "$pf" ]; then... test) - The
signal(2)/sigaction(2) to handle trapping the the Ctrl-C in the listen program.