Question: For this lab, you will implement your own version of the cat systems program, a standard Unix utility that reads files sequentially, writing them to

For this lab, you will implement your own version of the cat systems program, a standard Unix utility that reads files sequentially, writing them to standard output. The name is derived from its function to concatenate files. The Single Unix Specification defines the operation of cat to read files in the sequence given in its arguments, writing their contents to the standard output in the same sequence. If one of the input filenames is specified as a single hyphen (-), then cat reads from standard input at that point in the sequence. If no files are specified, cat reads from standard input only. The command-syntax is:

$ ./cat [file_name...]  

You are NOT allowed to use the exec, system, popen, and pclose system calls or functions in your implementation. You are not allowed to call the existing cat implementation. You must supply your own implementation that uses low-level I/O. Low-level file I/O (APUE Ch. 3) is a requirement for this breakout lab.

Some Nonfunctional Requirements:

Libraries: You are allowed to use any of the C or C++ standard libraries. When reading or writing to a file are concerned, you need to use low-level calls to read(2) and write(2) and related functions. You are NOT allowed to use the following system calls in any of your implementations: fork(2), execve(2), exec(3), popen(3), and system(3) (or related functions).

Unbuffered Output: Whenever possible, program output should be unbuffered. The best way to guarantee that output is unbuffered (i.e., characters at the destination as soon as possible) is to directly call write(2). If you are using printf(3), you should disable output buffering using setvbuf(3). If you are using C++ output streams (e.g., cout), then you should disable output buffering using setf and unitbuf .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!