Forward the right env data to subprocess call.

Closes #6123.