-
-
Save duobei/3899762 to your computer and use it in GitHub Desktop.
exec something on ruby.
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
#0> non-block call | |
Thread.new do | |
blahbla... | |
end | |
#1> 4 simple ways to call shell or cmd | |
`ps aux` | |
system "ps aux" | |
exec "ps aux" | |
%x{ ps aux } | |
#2> open3 popen & :pid | |
require 'open3' | |
Open3.popen2 "ps aux" do |i, o, t| | |
:pid = t.pid | |
end | |
#3> open3 capture & :pid | |
require 'open3' | |
o,s = Open3.capture2("ps aux") | |
:pid = s.pid | |
#4 Process spawn | |
:pid = Process.spawn "ps aux" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment