Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
* [sup-devel] [PATCH] Bugfix: Don’t call Ncurses.getch when in shell�out mode
@ 2010-02-19  3:26 Michael Stapelberg
  2010-02-27  8:23 ` [sup-devel] [PATCH] Bugfix: Don\xe2\x80\x99t call Ncurses.getch when in shell\x96out mode Rich Lane
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Stapelberg @ 2010-02-19  3:26 UTC (permalink / raw)
  To: sup-devel

[-- Attachment #1: Type: text/plain, Size: 527 bytes --]

Hi,

(at least for me) the attached patch finally fixes the pinentry-ncurses
problems we were still having (as soon as you press a key, the screen is
garbage).

To quote the commit message:

  Previously, when using threads, Ncurses.getch was called while
  the gpg pinentry was running (as an example of using the shell_out
  method). Now, the Ncurses mutex will be used to wait until shell_out
  mode is finished.

Please have a look if this patch is working for you and merge it for the next
release.

Best regards,
Michael

[-- Attachment #2: 0001-Bugfix-Don-t-call-Ncurses.getch-when-in-shell_out-mo.patch --]
[-- Type: application/octet-stream, Size: 2207 bytes --]

From 4d660530beeb42d192e2da594621b81ff991df10 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael@stapelberg.de>
Date: Fri, 19 Feb 2010 04:20:49 +0100
Subject: [PATCH] =?UTF-8?q?Bugfix:=20Don=E2=80=99t=20call=20Ncurses.getch=20when=20in=20shell=5Fout=20mode?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Previously, when using threads, Ncurses.getch was called while
the gpg pinentry was running (as an example of using the shell_out
method). Now, the Ncurses mutex will be used to wait until shell_out
mode is finished.
---
 bin/sup           |    2 +-
 lib/sup/buffer.rb |   11 +++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/bin/sup b/bin/sup
index 7824aca..c8eb5b9 100755
--- a/bin/sup
+++ b/bin/sup
@@ -243,7 +243,7 @@ begin
 
   until Redwood::exceptions.nonempty? || $die
     c = begin
-      Ncurses.nonblocking_getch
+      Ncurses.nonblocking_getch BufferManager
     rescue Interrupt
       raise if BufferManager.ask_yes_or_no "Die ungracefully now?"
       BufferManager.draw_screen
diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
index c82fca0..84b3d00 100644
--- a/lib/sup/buffer.rb
+++ b/lib/sup/buffer.rb
@@ -30,13 +30,19 @@ module Ncurses
   def mutex; @mutex ||= Mutex.new; end
   def sync &b; mutex.synchronize(&b); end
 
-  def nonblocking_getch
+  def nonblocking_getch bm=nil
     ## INSANTIY
     ## it is NECESSARY to wrap Ncurses.getch in a select() otherwise all
     ## background threads will be BLOCKED. (except in very modern versions
     ## of libncurses-ruby. the current one on ubuntu seems to work well.)
     if IO.select([$stdin], nil, nil, 0.5)
-      c = Ncurses.getch
+      if bm && bm.shelled?
+        # If we got input while we are shelled, we will drop the input
+        # but use Ncurses.sync to wait until the shell_out is done.
+        Ncurses.sync { nil }
+      else
+        Ncurses.getch
+      end
     end
   end
 
@@ -216,6 +222,7 @@ EOS
   def sigwinch_happened?; @sigwinch_mutex.synchronize { @sigwinch_happened } end
 
   def buffers; @name_map.to_a; end
+  def shelled?; @shelled; end
 
   def focus_on buf
     return unless @buffers.member? buf
-- 
1.6.5


[-- Attachment #3: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-02-27 20:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-19  3:26 [sup-devel] [PATCH] Bugfix: Don’t call Ncurses.getch when in shell�out mode Michael Stapelberg
2010-02-27  8:23 ` [sup-devel] [PATCH] Bugfix: Don\xe2\x80\x99t call Ncurses.getch when in shell\x96out mode Rich Lane
2010-02-27 12:48   ` Michael Stapelberg
2010-02-27 18:12     ` Rich Lane
2010-02-27 19:00       ` [sup-devel] [PATCH] Bugfix: Don't call Ncurses.getch when in shell-out mode William Morgan
2010-02-27 19:03         ` Rich Lane
2010-02-27 19:29           ` William Morgan
2010-02-27 19:27       ` [sup-devel] [PATCH] Bugfix: Don\xe2\x80\x99t call Ncurses.getch when in shell\x96out mode Michael Stapelberg
2010-02-27 20:14         ` Rich Lane

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox