You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Basically, it appears that if you open a pipe, then the main thread exits, other threads still running "stop begin able to write to that pipe" (my assumption is it was closed when the main thread exited). I think I've run into this before, but couldn't find a ticket for it easily, so sorry if it's a dupe. It seems to reproduce at least in windows 7 with jdk 1.6 and windows xp with jdk 7.
This snippet should output 'hello'
javax.swing.JFrame.new.show
a = IO.popen("jruby -e 'puts gets'", "w")
sleep 1 # let it start
timer = javax.swing.Timer.new(1000, nil)
timer.repeats=false # may not be necessary
timer.add_action_listener {
a.puts 'hello'
}
timer.start
# allow main thread to exit -- uncomment the sleep line and it works as expected.
# sleep
as is, it responds with
Exception in thread "AWT-EventQueue-0" org.jruby.exceptions.RaiseException: (Errno::EBADF) Bad file descriptor
at org.jruby.RubyIO.write(org/jruby/RubyIO.java:1399)
at org.jruby.RubyIO.write(org/jruby/RubyIO.java:2376)
at org.jruby.RubyIO.puts(org/jruby/RubyIO.java:2331)
at org.jruby.RubyIO.puts(org/jruby/RubyIO.java:2323)
at bad.(root)(bad.rb:10)
at org.jruby.gen.InterfaceImpl1035124051.actionPerformed(org/jruby/gen/InterfaceImpl1035124051.gen:13)
or within a larger program:
Errno::EBADF: Bad file descriptor - Bad file descriptor
read at org/jruby/RubyIO.java:2904
` at file:/C:/installs/jruby-1.7.0/lib/jruby.jar!/jruby/kernel/jruby/process_manager.rb:35
` at file:/C:/installs/jruby-1.7.0/lib/jruby.jar!/jruby/kernel/jruby/process_manager.rb:49
set_all_ffmpegs_as_lowest_prio at C:/dev/dirt-simple-usb-surveillance/./lib/go.rb:17
do_something at C:/dev/dirt-simple-usb-surveillance/./lib/go
.rb:99
IOError: Stream closed
The difficult thing with this is that the errors sometimes can manifest themselves "unreliably" because it depends if the main thread has exited yet or not. In my case, sometimes it has, sometimes it hasn't, which makes this a frustrating bug to trace.
The text was updated successfully, but these errors were encountered:
This is unlikely to be fixed now or ever; we'd need to know that one of the many JVM threads is a user thread still active in the system and still dependent on the streams we shut down on exit. The lifecycle of the JRuby instance is only as long as the lifecycle of "main" when running from the command line. If you want to keep it valid longer than that, wait for those threads to shut down in your main thread or block the main thread until it's safe to exit. Treat script exit like app exit.
From http://jira.codehaus.org/browse/JRUBY-7041
Original report
Basically, it appears that if you open a pipe, then the main thread exits, other threads still running "stop begin able to write to that pipe" (my assumption is it was closed when the main thread exited). I think I've run into this before, but couldn't find a ticket for it easily, so sorry if it's a dupe. It seems to reproduce at least in windows 7 with jdk 1.6 and windows xp with jdk 7.
This snippet should output 'hello'
as is, it responds with
or within a larger program:
The difficult thing with this is that the errors sometimes can manifest themselves "unreliably" because it depends if the main thread has exited yet or not. In my case, sometimes it has, sometimes it hasn't, which makes this a frustrating bug to trace.
The text was updated successfully, but these errors were encountered: