Part 3. Adding usernames to ps (10 points)
Now that user::username()
has been implemented, modify your ps
to use user::username()
.
Your task
Modify your implementation of ps
to print out a left-aligned column with the
username when the -f
option is passed and a right-aligned column with the
UID when -l
but not -f
is passed.
$ cargo run --bin ps --quiet -- -f
UID PID PPID TTY TIME CMD
steve 1519068 1518177 34816 0 /bin/bash --init-file /zfs/faculty/steve/.vscode-server/bin/f1b07bd25dfad64b0167beb15359ae573aecd2cc/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh
steve 1521087 1519068 34816 0 target/debug/ps -f
$ cargo run --bin ps --quiet -- -l
S UID PID PPID TTY TIME CMD
S 1425750506 1519068 1518177 34816 0 bash
R 1425750506 1521098 1519068 34816 0 ps
$ cargo run --bin ps --quiet -- -fl
S UID PID PPID TTY TIME CMD
S steve 1521440 1518177 34819 0 /bin/bash --init-file /zfs/faculty/steve/.vscode-server/bin/f1b07bd25dfad64b0167beb15359ae573aecd2cc/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh
R steve 1521657 1521440 34819 0 target/debug/ps -fl