This program was designed on and for FreeBSD 14.1 and serves as the second homework assignmen for the class CS631 Advanced Programming in the Unix Environment, taught by the wonderful Jan Schaumann. While the course is desgned around NetBSD, I am implementing the assignments in FreeBSD 14.1 as it is the operating system I am running on my laptop and the slight differences in the various Unix-like operating systems make things fun for learning!
The objective of this assignment is to apply the lessons of Unix Interprocess Communication from the video lectures and textbook (Steven's Advanced Programming in the Unix Environment 3rd Edition), and to write a tool which requirescommunication between two related processes using the pipe(2) system call.
Full details of the assignment can be found here.
Write a function command(3) as described in the manual page. The code should run successfully when used in the following main() function:
int
main() {
char out[BUFSIZ] = { 0 }, err[BUFSIZ] = { 0 };
if (command("ls -l", out, BUFSIZ-1, err, BUFSIZ-1) == -1) {
perror("command");
exit(EXIT_FAILURE);
}
out[BUFSIZ-1] = '\0';
err[BUFSIZ-1] = '\0';
printf("stdout:\n%s\n", out);
printf("stderr:\n%s\n", err);
return EXIT_SUCCESS;
}
To build the program, follow these steps:
- Navigate to the mainn directory of the program.
- Run the following commands:
make
To remove only the object files created during the compilation process run the following command
make clean-obj
To remove all files, including the binary, run the following
make clean
./command_app