Query process information in C++ on linux and/or unix.

I have a created a program that forks off another program, and maintains status information about each process.

std::map::iterator it;
std::map tmpDisplay = Displays;
for (it = tmpDisplay.begin(); it != tmpDisplay.end(); ++it) {
stringstream filename;
stringstream log;
filename<<"/proc/"<second.pid();
ifstream file(filename.str().c_str());
if(!file) {
StopOrKillDisplay(it->second, false);
log<<"Removing closed process ("<second.pid()<<")"; Log.write(log.str()); } }

Once in a while you come across some information that is pretty interesting. The proc manpage has a lot of good information! Here I am simply inferring that if the directory named from the current pid of the process am interested in does not exist, it is not running. I can then do some cleanup and free those resources maintained by my program.

man proc