-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return non-zero exit codes when something goes wrong
- Loading branch information
Flavio Auciello
committed
Apr 28, 2017
1 parent
c0b2ce3
commit 018a129
Showing
9 changed files
with
111 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'open3' | ||
|
||
module Pulsar | ||
module Executor | ||
def self.sh(cmd) | ||
stdin_stream, stdout_stream, stderr_stream, wait_thr = Open3.popen3(cmd) | ||
stdout = stdout_stream.gets(nil) || "" | ||
stderr = stderr_stream.gets(nil) || "" | ||
stdout_stream.close | ||
stderr_stream.gets(nil) | ||
stderr_stream.close | ||
stdin_stream.close | ||
exit_code = wait_thr.value | ||
yield exit_code, stdout, stderr if block_given? | ||
{ status: exit_code.exitstatus, output: stdout + stderr } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.