set pid_=-1 after wait, actually implement pid()
authorTudor Bosman <tudorb@fb.com>
Wed, 16 Jan 2013 22:52:04 +0000 (14:52 -0800)
committerJordan DeLong <jdelong@fb.com>
Sat, 19 Jan 2013 00:38:16 +0000 (16:38 -0800)
Summary: minor issues in folly::Subprocess

Test Plan: subprocess_test

Reviewed By: philipp@fb.com

FB internal diff: D680959

folly/Subprocess.cpp

index da69e5368e4649f1da07317e9b432077b9b6ffdb..1470a7066384bb66c1f81732fcce7c7385e2e0aa 100644 (file)
@@ -427,6 +427,7 @@ ProcessReturnCode Subprocess::wait() {
   checkUnixError(found, "waitpid");
   DCHECK_EQ(found, pid_);
   returnCode_ = ProcessReturnCode(status);
+  pid_ = -1;
   return returnCode_;
 }
 
@@ -441,6 +442,10 @@ void Subprocess::sendSignal(int signal) {
   checkUnixError(r, "kill");
 }
 
+pid_t Subprocess::pid() const {
+  return pid_;
+}
+
 namespace {
 
 std::pair<const uint8_t*, size_t> queueFront(const IOBufQueue& queue) {