rendered paste body// pid-mon.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
main(int argc, char *argv[]){
FILE *stream;
char sigstat[20],pidloc[] = "/proc/%s/status",openme[sizeof pidloc+100],buf[100];
if (argc < 2){
printf("usage: ./pid-mon pid\n");
exit(1);
}
sprintf(openme, pidloc, argv[1]);
if((stream = fopen(openme,"r")) == NULL){
printf("Name: Unavilable\nState: MIA\n", pidloc);
exit(1);
}
fgets(buf, 30, stream);
printf("%s",buf);
fgets(buf, 30, stream);
printf("%s",buf);
} //MAIN