C
Claudio Jeker
I'm a bit stuck with this porblem:
I need to write data to a process and then wait for the exit code of it to
see if it was successful or not.
Now I can IO.popen the process but there is no pclose instance method to
get the exitcode back. Additionally my workaround via Process.waitpid2 does
not work either. I think io.close does already all the cleanup.
e.g.
io = IO.popen(cmd, "w")
io.write(msg)
io.close
pid, status = Process.waitpid2(0)
Raises a "Errno::ECHILD: No child processes" exception.
How do other handle this situation? Do I need to take the hard road via
pipe, fork, exec or did I miss something obvious?
I need to write data to a process and then wait for the exit code of it to
see if it was successful or not.
Now I can IO.popen the process but there is no pclose instance method to
get the exitcode back. Additionally my workaround via Process.waitpid2 does
not work either. I think io.close does already all the cleanup.
e.g.
io = IO.popen(cmd, "w")
io.write(msg)
io.close
pid, status = Process.waitpid2(0)
Raises a "Errno::ECHILD: No child processes" exception.
How do other handle this situation? Do I need to take the hard road via
pipe, fork, exec or did I miss something obvious?