C-Shell
A simple shell written in C.
Loading...
Searching...
No Matches
pinfo.c File Reference
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include "../internal_commands.h"

Functions

int pinfo (pid_t pid)
 

Function Documentation

◆ pinfo()

int pinfo ( pid_t pid)

Sample output:

pid -- 231
Process Status -- {R/S/S+/Z}
memory -- 67854 {Virtual Memory}
Executable Path -- ./cshell

Process status codes:

  1. R/R+: Running
  2. S/S+: Sleeping in an interruptible wait
  3. Z: Zombie
  4. T: Stopped (on a signal)

Note: “+” must be added to the status code if the process is in the foreground.

Parameters
pidpid of the process, -1 for the parent process, 0 for the current process
Returns
int 0 on success, -1 on failure