From mboxrd@z Thu Jan 1 00:00:00 1970 From: wmorgan-sup@masanjin.net (William Morgan) Date: Thu, 06 Aug 2009 10:53:43 -0700 Subject: [sup-talk] sup ignoring SIGTERM? In-Reply-To: <1249507336-sup-7887@masanjin.net> References: <1249481294-sup-9967@chistera.yi.org> <1249502171-sup-8079@masanjin.net> <1249503870-sup-1415@ausone.home> <1249507336-sup-7887@masanjin.net> Message-ID: <1249581215-sup-2548@masanjin.net> Reformatted excerpts from William Morgan's message of 2009-08-05: > The problem is the removal of the select() in nonblocking_getch > (buffer.rb circa line 25). With it in, resizes don't work right. With > it removed, background threads are blocked on some computers. Not sure > what makes the difference. Sigh... Ok, I've tracked this down. FWIW, this is a problem that's been around in ruby ncurses libraries since at least 2005, when I complained about it on ruby-core. In many ruby ncurses libraries, including the most recent gem, Ncurses.getch blocks all Ruby threads from running. That's a bug. The workaround is to wrap it in a select() call. But then you have to handle sigwinch manually (i.e via Kernel#trap), because getch won't return a resize "keystroke" until the user hits an actual key. The libncurses-ruby library on modern Ubuntu systems actually doesn't have this problem. You can set nodelay false, throw out the select call, and everything works the way it's supposed to: background threads run, and you get a resize keystroke when a sigwinch happens without you having to install your own handler. And that's the library I had been developing against, which is why everything worked on one computer but didn't work on the others. Anyways, for those who were having problems with this branch before, please try the most recent version and confirm that: 1. Email threads load as normal, i.e. in the background. 2. Resizing the terminal refreshes the screen without you having to press any keys. 3. Ctrl-l still works. 4. Ctrl-c still works (prompts you, and y/n do the right thing). 5. Killing Sup works. If everyone's happy, I'll merge this branch into next. If you're curious about whether you have a good or bad ncurses library, run this program: (But either should work correctly with Sup.) require 'rubygems' require 'ncurses' require 'thread' Ncurses.initscr Ncurses.noecho Ncurses.cbreak Ncurses.curs_set 0 Thread.new do sleep 0.1 Ncurses.stdscr.mvaddstr 0, 0, "ncurses library is GOOD." end begin Ncurses.stdscr.mvaddstr 0, 0, "ncurses library is BAD." Ncurses.getch ensure Ncurses.curs_set 1 Ncurses.endwin puts "bye" end -- William