factor out broken environment handling. introduce process_info struct. next try.
closest we've ever been to correctly handling local, direct and export environments. And only a single error in valgrind.