Skip to content

Commit

Permalink
Add folly::Subprocess::ProcessReturnCode::succeeded()
Browse files Browse the repository at this point in the history
Summary:
This diff adds folly::Subprocess::ProcessReturnCode::succeeded(), a convenience method for determining whether a subprocess exited normally with a zero exit status.

This is equivalent to Rust's std::process::ExitStatus::success(), but using a slightly different name to align with existing methods (e.g. exited(), killed(), coreDumped(), etc.).

Reviewed By: jdonald, ot, luciang

Differential Revision: D48333616

fbshipit-source-id: 71232bbdb6824f876d456c35d71ed898d4397c85
  • Loading branch information
J.T. Conklin authored and facebook-github-bot committed Aug 18, 2023
1 parent 152fb9f commit a1a57a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions folly/Subprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ bool ProcessReturnCode::coreDumped() const {
return WCOREDUMP(rawStatus_);
}

bool ProcessReturnCode::succeeded() const {
return exited() && exitStatus() == 0;
}

std::string ProcessReturnCode::str() const {
switch (state()) {
case NOT_STARTED:
Expand Down
5 changes: 5 additions & 0 deletions folly/Subprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ class ProcessReturnCode {
*/
bool coreDumped() const;

/**
* Process exited normally with a zero exit status
*/
bool succeeded() const;

/**
* String representation; one of
* "not started"
Expand Down

0 comments on commit a1a57a6

Please sign in to comment.