{"issue":{"user":{"id":1299,"login":"mitchellh","url":"https://api.github.com/users/mitchellh","gravatar_id":"2828f28fb012308a7786eee83b8293c5","avatar_url":"https://secure.gravatar.com/avatar/2828f28fb012308a7786eee83b8293c5?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"milestone":null,"created_at":"2011-12-19T02:00:14Z","title":"Detecting a failure to execute the process ","updated_at":"2011-12-20T21:23:39Z","labels":[],"state":"closed","id":2596204,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"html_url":"https://github.com/jarib/childprocess/issues/18","closed_at":"2011-12-20T21:23:39Z","number":18,"body":"ChildProcess currently doesn't provide a uniform way to detect that there was a failure to execute the given process. Java differs from Linux which differs from Windows. \r\n\r\nIt would be nice if there was a uniform error I could catch that would signal that ChildProcess wasn't able to start the childprocess... though I'm not sure how to do that easily portably. \r\n\r\nIn the mean time, I'm building it in to a helper to catch the various exit cases...\r\n\r\nFor example, executing `foo bar baz`...\r\n\r\n## On Linux\r\n\r\nThe following comes through via the `stderr` of the child process:\r\n\r\n```\r\n/Users/mitchellh/.rvm/gems/ruby-1.9.3-p0/gems/childprocess-0.2.3/lib/childprocess/unix/process.rb:94:in `exec': No such file or directory - foo (Errno::ENOENT)\r\n\tfrom /Users/mitchellh/.rvm/gems/ruby-1.9.3-p0/gems/childprocess-0.2.3/lib/childprocess/unix/process.rb:94:in `block in launch_process'\r\n\tfrom /Users/mitchellh/.rvm/gems/ruby-1.9.3-p0/gems/childprocess-0.2.3/lib/childprocess/unix/process.rb:83:in `fork'\r\n\tfrom /Users/mitchellh/.rvm/gems/ruby-1.9.3-p0/gems/childprocess-0.2.3/lib/childprocess/unix/process.rb:83:in `launch_process'\r\n\tfrom /Users/mitchellh/.rvm/gems/ruby-1.9.3-p0/gems/childprocess-0.2.3/lib/childprocess/abstract_process.rb:58:in `start'\r\n\tfrom /Users/mitchellh/code/personal/ruby/vagrant/lib/vagrant/util/subprocess.rb:37:in `execute'\r\n\tfrom /Users/mitchellh/code/personal/ruby/vagrant/lib/vagrant/util/subprocess.rb:15:in `execute'\r\n\tfrom test.rb:7:in `<main>'\r\n```\r\n\r\n## On Java\r\n\r\nThe following exception is raised directly in the parent process:\r\n\r\n```\r\nNativeException: java.io.IOException: Cannot run program \"foo\" (in directory \"/Users/mitchellh/code/personal/ruby/vagrant\"): error=2, No such file or directory\r\n  launch_process at /Users/mitchellh/.rvm/gems/jruby-1.6.5/gems/childprocess-0.2.3/lib/childprocess/jruby/process.rb:59\r\n           start at /Users/mitchellh/.rvm/gems/jruby-1.6.5/gems/childprocess-0.2.3/lib/childprocess/abstract_process.rb:58\r\n         execute at /Users/mitchellh/code/personal/ruby/vagrant/lib/vagrant/util/subprocess.rb:37\r\n         execute at /Users/mitchellh/code/personal/ruby/vagrant/lib/vagrant/util/subprocess.rb:15\r\n          (root) at test.rb:7\r\n```\r\n\r\n## On Windows\r\n\r\n(I haven't tested on Windows, sorry, but I imagine it will be different)","url":"https://api.github.com/repos/jarib/childprocess/issues/18","comments":2,"assignee":null},"action":"closed"}