How to run exe asynchronously with two arguments in ruby?

exe should start when i open the page. You must start the asynchronous process.

Is there a way to run exe asynchronously with two arguments in ruby?

I tried the ruby ​​commands - system (), exec (), but was expecting the process to complete. I need to run exe with a parameter, no need to wait for the process to complete

- any rubigems that will support my problem?

+5
source share
2 answers

You can use Process.spawnand Process.wait2:

pid = Process.spawn 'your.exe', '--option'

# Later...
pid, status = Process.wait2 pid

Your program will be executed as a child process of the interpreter. In addition, it will behave as if it were called from the command line.

You can also use Open3.popen3:

require 'open3'
*streams, thread = Open3.popen3 'your.exe', '--option'

# Later...
streams.each &:close
status = thread.value

, IO. , .

, . , , script.

, , .

+7

exec . system .

, , , fork, exec, , . win32ole, .

+1

All Articles