Update Subprocess to throw if exec() fails
authorAdam Simpkins <simpkins@fb.com>
Tue, 16 Apr 2013 00:58:47 +0000 (17:58 -0700)
committerSara Golemon <sgolemon@fb.com>
Mon, 20 May 2013 18:01:27 +0000 (11:01 -0700)
commit9cbe659479b0271da0376b0ec50a21723d484e25
tree7f75215d32008fa85b9b7d1042d767f3fa3be998
parent94ddd29dd7b11f3f07f7e1c92e8a57bc2b1f621f
Update Subprocess to throw if exec() fails

Summary:
Add a new SubprocessSpawnError, and change the Subprocess constructor to
throw this if the child process encounters an error before calling
execve().  Error information is passed back to the parent process over a
pipe.

Previosly in this case the Subprocess constructor would fail, and
clients would simply get a return code of 126 or 127 when waiting on the
process.  There was no way to distinguish this from a successful
execve() followed by the child process exiting with status 127.

Test Plan:
Added tests to check the exception behavior, and also to check for file
descriptor leaks in the parent process.

Reviewed By: tudorb@fb.com

FB internal diff: D776273
folly/ScopeGuard.h
folly/Subprocess.cpp
folly/Subprocess.h
folly/test/SubprocessTest.cpp