// pid-mon.c #include #include #include #include #include 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