Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
From: Michael Stapelberg <michael+sup@stapelberg.de>
To: sup-devel <sup-devel@rubyforge.org>
Subject: [sup-devel] [PATCH] Bugfix: Don’t call Ncurses.getch when in shell�out mode
Date: Fri, 19 Feb 2010 04:26:37 +0100	[thread overview]
Message-ID: <1266549876-sup-2041@midna.zekjur.net> (raw)

[-- 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

             reply	other threads:[~2010-02-19  3:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-19  3:26 Michael Stapelberg [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1266549876-sup-2041@midna.zekjur.net \
    --to=michael+sup@stapelberg.de \
    --cc=sup-devel@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox