However, parsing the environ file is proving to be a royal pain in the arse. I got over the first hurdle of dealing with a bunch of NUL terminated strings. I've also been able to split the string on the '=' sign and turn them into key/value pairs. I've hit two snags (so far), however.
The first is that sometimes this file can be empty. Right now that causes a segfault. You can't simply stat the file either - environ files are always size 0. The read and fread functions can't be relied on either. I'm going to play with lseek to see if that will work.
The second is that not all the environ files contain data in "KEY=/some/val" format. I found one that simply contained the string "--suicide", which I thought was appropriate, since it succeeded in killing my program. This could actually be a bigger problem. What should I do for a case like this? I'm thinking of just making the whole string the key, and assigning '1' as the value.
Of course, I could just be a bum and return everything as a big, ugly string for YOU to parse.