Make Subprocess::spawn more robust
authorTudor Bosman <tudorb@fb.com>
Sat, 13 Apr 2013 06:49:32 +0000 (23:49 -0700)
committerJordan DeLong <jdelong@fb.com>
Sun, 21 Apr 2013 20:21:25 +0000 (13:21 -0700)
commite33bebd37a24287368fdebc0d085d7319083ba08
tree9dc27cd9afe5f1456cce3631385d15ce71a6fc8a
parent570ec3333e183881ffe326fe64c97605a92008d1
Make Subprocess::spawn more robust

Summary:
We can't throw after the process is created, because we don't know what to do
with it (and the Subprocess object goes up in smoke, so we can't rely on the
caller to clean up, either).  So don't throw.

If we throw before the process is created, make sure we clean up.

Test Plan: subprocess_test

Reviewed By: delong.j@fb.com

FB internal diff: D774722
folly/Subprocess.cpp
folly/test/SubprocessTest.cpp