Moved subprocess and cleanup method to new cpp.

Review: https://reviews.apache.org/r/19416
Added optional environment map to subprocess.

Review: https://reviews.apache.org/r/19162