GithubHelp home page GithubHelp logo

background_process's People

Contributors

timcharper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

pavan123k

background_process's Issues

PTYBackgroundProcess.run won't work but BackgroundProcess.run does

Hi Tim,

for unknown reason "PTYBackgroundProcess.run" does not work on my Ubuntu 11.10, but "BackgroundProcess.run" will. Please find a minimal example here: http://pastebin.com/G2piFfN8

So the problem is somehow related to PTY, but I am unsure how to debug the issue. The VM is a very minimalistic Ubuntu 11.10, so are there any packages, tools or user-rights required?

To give you some broader scope, I have some trouble running cucumber (1.1.9) together with service manager (0.6.3) with Ruby 1.8.7 on Ubuntu 11.10. So I debugged the problem down to background process (1.3) not working for some reason.

It would be really awesome to get some feedback. I am happy to provide more details, logs, etc
Thanks! Jens

Handling Buffer overflow in STDOUT

I have forked a project (aruba) which uses background_process. This is employed to run out of process software testing using cucumber. The problem that I have is that in some test cases the output to stdout is quite voluminous. In Ruby-1.8.7 this is not a problem. However, when I run the tests with Ruby-1.9.2 what appears to happen is a block on write is encountered because, I infer, the STDOUT buffer is not flushed and some limit is reached. I infer this from the fact that the test run which hangs is always the same one and that breaking out of the process shows STDOUT always at the same point and the last instruction is the same write to STDOUT. As I say, this is a Ruby-1.9.2 problem only.

The code block in Aruba looks like this:

    def run(cmd, fail_on_error=true)
      cmd = detect_ruby(cmd)

      in_current_dir do
        announce_or_puts("$ cd #{Dir.pwd}") if @announce_dir
        announce_or_puts("$ #{cmd}") if @announce_cmd
        ps = BackgroundProcess.run(cmd)
        @last_exit_status = ps.exitstatus # waits for the process to finish
        @last_stdout = ps.stdout.read
        announce_or_puts(@last_stdout) if @announce_stdout
        @last_stderr = ps.stderr.read
        announce_or_puts(@last_stderr) if @announce_stderr
      end

      if(@last_exit_status != 0 && fail_on_error)
        fail("Exit status was #{@last_exit_status}. Output:\n#{combined_output}")
      end

      @last_stderr
    end

As you can see, replacing BackgroundProcess.run(cmd) with PTYBackgroundProcess.run(cmd) will not suffice since then the exit status and stderr are either unavailable or unusable. I tried inserting STDOUT.sync = true immediately before the call to BackgroundProcess.run but this did not change the behaviour.

Is there a technique to force the STDOUT buffer to flush that is callable either from inside Cucumber or BackgroundProcess itself.?

Any advice or insight into how to approach this problem would be deeply appreciated.

pty_background_process.rb depends on PTY::ChildExited which doesn't exist in JRuby 1.6.7

The relevant parts of the traceback

NameError: uninitialized constant PTY::ChildExited
const_missing at org/jruby/RubyModule.java:2642
wait at <....>/gems/background_process-1.3/lib/background_process/pty_background_process.rb:41

If we comment out line 46 and 47 as shown:

rescue PTY::ChildExited

true

Then everything seems to be hunky-dory (using background_service as the client component).

Some suggest solving this without having to comment out code under jruby:

1. Monkey patch the PTY module if ChildExited exception is not present:

unless PTY.constants.include?(:ChildExited)
  module PTY
    class ChildExited < RuntimeError
    end
  end
end

2. Fix the jruby pty module to include the ChildExited exception even though it is not used

3. Have alternate rescue clauses for rubies that don't have the PTY::ChildExited exception

Kill doesn't work on Ubuntu

When we issue a @process.kill on ubuntu it doesn't kill it (even if we use INT). Digging in a little it looks like @process.id is the wrong pid, hence kill doesn't work.

On Ubuntu when the process is run, it runs "sh -c [my command]", which then spawns the actual command. This appears to be different from OS X where the command is executed directly (as the ruby doc implies would happen).

I assume(?) that it's the extra "sh -c" process that's causing the pid to be incorrect, since it's pointing at the "sh -c" process rather than the real command process.

We're stuck. Any help appreciated, and happy to work on it with you.

Aish

PS. The same script is working fine on OS X.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.