Backport of subprocess code to support 2.6