Lab 6: Processes I
Due: 2024-10-28 at 23:59
In this lab and the next, you are going to write several command line applications that work with processes. You will use the same repository for both labs.
The goal is to learn
- how to create a library and binaries in the same project;
- how to create a module;
- one way to implement generic error handling;
- how to define new
struct
s and implement methods for them; - how to call functions in the C standard library to interact with the operating system;
- about how Linux exposes information to users via the
/proc
file system; and - how processes, process groups, sessions, and terminals all fit together!
Unlike the previous labs, the next two are going to be specific to Linux. Windows, macOS, and other operating systems use different mechanisms to expose information to user programs. See the instructions for remote coding.
In the first part of this lab, you’re going to create a Rust project that
contains both a library and a binary. In the second part of the lab, you’re
going to copy the type alias Result<T>
you created in the last lab to this
lab because it’s extremely useful. In the third part, you’ll read information
from /proc
. In the remaining parts of this lab, you’re going to implement a
process
library that will contain functions that return information about
running processes as well as most of an implementation for the ps
command
line tool which displays information about processes.
Preliminaries
First, find a partner. You’re allowed to work by yourself, but I highly recommend working with a partner. Click on the assignment link. One partner should create a new team. The team name cannot be the same name used for a previous lab. The second partner should click the link and choose the appropriate team. (Please don’t choose the wrong team, there’s a maximum of two people and if you join the wrong one, you’ll prevent the correct person from joining.) You cannot choose a team name you’ve used previously.
Once you have accepted the assignment and created/joined a team, you can clone the repository and begin working.
Be sure to ask any questions on Ed.
Compiler warnings and errors
Make sure your code compiles and passes clippy
without errors or warnings.
That is, running
$ cargo clean
$ cargo build
$ cargo clippy
should build your program without errors or warnings.
Formatting
Your code must be formatted by running cargo fmt
.