2

I want to create multiple processes (each with cmd + arguments).

I need the pid of the created process so I can kill it if needed.

I also want to be able to read its output (line-by-line) in a non-blocking way (otherwise I have to create threads which I would like to avoid). Feeding its standard input is a bonus.

What's the best way to do this in ruby?

1 Answer 1

1

Use IO.popen to fork the process (it will return a IO object with a pid method corresponding to the forked process). You can select on the IO object to avoid blocking.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.