From: "Ara.T.Howard" Date: 2005-05-26T13:59:02+09:00 Subject: Re: Killing a Process started with Kernel.system On Thu, 26 May 2005, nobuyoshi nakada wrote: > Hi, > > At Wed, 25 May 2005 03:42:13 +0900, > Ara.T.Howard wrote in [ruby-talk:143556]: >> input, out, err, pid = Open4.popen4(command) >> >> it would be great to wrap this up and get it into ruby - that way there would >> be a standard way to write portable (in some fashion) programs that spawn >> external commands. my current project, dirwatch, which watches a directory >> for events and spawns user defined actions for them needs just such a thing. > > That interface feels ugly to me. > > Once I thought like: > > child = Process.spawn([cmd, *arg], STDIN=>input, STDOUT=>output, STDERR=>err) > Process.waitpid(child.pid) > > but not sure yet. but maybe child.wait #=> Process::Status i have code that does just that. the reason for open4 is just to provide a toolset for coding the above ;-) now that there is a way to get stdin, stdout, stderr, and cid on both windoze and *nix perhaps a package to do just that could be added to the stdlib? regards. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | My religion is very simple. My religion is kindness. | --Tenzin Gyatso ===============================================================================