Question: Linux/ Unix system The /PROC File System Make your own ps command named Myps. Frist Your assignment is to write a simpler version of the
Linux/ Unix system The /PROC File System
Make your own ps command named Myps.
Frist Your assignment is to write a simpler version of the ps command. Your version of ps, called MYps will be executed from a command line. It will read a variety of information about one or more running programs (processes) on the computer, and then display that information. As an example of what your program will do, consider a command such as:
MYps -p 1234 -s -U -c The /proc Filesystem The /proc file system provides access to the state of each active process and thread in the system. The /proc file system contains a directory entry for each process running on the Linux system. The name of each directory in the filesystem is the process ID of the corresponding process. These directories appear and disappear dynamically as processes start and terminate on the system. Each directory contains several entries providing access to information about the running process. From these process directories the /proc file system gets its name. These entries are subdirectories and the owner of each is determined by the user ID (PID) of the process. Access to the process state is provided by additional files contained within each subdirectory. Except where otherwise specified, the term /proc file is meant to refer to a non- directory file within the file hierarchy rooted at /proc. /proc is known as a "pseudo-filesystem", which means it is not a true filesystem that is consuming disk storage. The files and directories in /proc are entry points into kernel tables, such as the table of open files or the process table. Some of the directories in the /proc filesystem are: directory description /proc/PID/cmdline Command line arguments. /proc/PID/cpu Current and last cpu in which it was executed. /proc/PID/cwd Link to the current working directory. /proc/PID/environ Values of environment variables. /proc/PID/exe Link to the executable of this process. /proc/PID/fd Directory, which contains all file descriptors. /proc/PID/maps Memory maps to executables and library files. /proc/PID/mem Memory held by this process. /proc/PID/root Link to the root directory of this process. /proc/PID/stat Process status. /proc/PID/statm Process memory status information. /proc/PID/status Process status in human readable form.
Myps should have those features Project Features Your program will implement the features triggered by the following options for the ps command. -p
Options processing: This module will process the command line options, setting state variables to record what the options specify.
Getting the process list: If there is no -p option, then you will need to look through /proc to find the list of processes belonging to the user. This module should implement that functionality.
stat and statm parser: This module will extract strings from the space-separated lists that are read from the stat and statm files. Checklist
| Options Processing |
| Parsing Commandline Opions |
| recording options into variables for use in code |
| Scan through /proc to find the list of processes |
| Parse individual files in the /proc directory |
| extract strings from the lists read from the stat & statm files |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
