Skip to content
This repository

Unix signals travel to handlers very slowly #42

Closed
Pipeliner opened this Issue September 24, 2012 · 2 comments

2 participants

Pipeliner Jason Thomas
Pipeliner

I'm new to Ruby, Qt and Unix signals so the following code may just be incorrect:

require 'Qt4'
trap ("HUP") { puts "Sighupped" }
puts "Run in different terminal windows:" 
puts "strace -tp #{$$}"
puts "kill -HUP #{$$}"

a = Qt::Application.new ARGV
b = Qt::PushButton.new "I'm a button"
b.show

a.exec

It prints following strace log for me (relevant part):

01:44:18 poll([{fd=5, events=POLLIN}, {fd=9, events=POLLIN}, {fd=10, events=POLLIN}, {fd=8, events=POLLIN}], 4, -1) = ? ERESTART_RESTARTBLOCK (To be restarted)
01:44:21 --- SIGHUP (Hangup) @ 0 (0) ---
01:44:21 write(4, "!", 1)               = 1
01:44:21 rt_sigreturn(0x2)              = -1 EINTR (Interrupted system call)
01:44:21 read(5, 0x7fff6ef97cb0, 16)    = -1 EAGAIN (Resource temporarily unavailable)
01:44:21 recvfrom(8, 0x1245e94, 4096, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)
01:44:21 recvfrom(8, 0x1245e94, 4096, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)
01:44:21 poll([{fd=5, events=POLLIN}, {fd=9, events=POLLIN}, {fd=10, events=POLLIN}, {fd=8, events=POLLIN}], 4, -1) = 1 ([{fd=8, revents=POLLIN}])
01:44:58 read(5, 0x7fff6ef97cb0, 16)    = -1 EAGAIN (Resource temporarily unavailable)
01:44:58 recvfrom(8, "\34\0/\1\266\0\0\0'\1\0\0\271wR\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096, 0, NULL, NULL) = 32
01:44:58 recvfrom(8, 0x1245e94, 4096, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)
01:44:58 rt_sigprocmask(SIG_SETMASK, ~[SEGV VTALRM RTMIN RT_1], NULL, 8) = 0
01:44:58 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
01:44:58 write(1, "Sighupped", 9)       = 9
01:44:58 write(1, "\n", 1)              = 1
01:44:58 recvfrom(8, 0x1245e94, 4096, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)

And 38 seconds was not the worst case. )
By the way, I was to make my application react to global keyboard shortcut what is not supported in default Qt. So I wanted to bind global shortcut to shellscript that sighups my app Can you please suggest another method?

Jason Thomas
Collaborator

I don't know how to create something that responds to a keyboard shortcut if the application window doesn't have focus. If you can allow the application to have focus you can do something like this: http://stackoverflow.com/questions/4341492/respond-to-application-wide-hotkey-in-qt

Pipeliner

Well, it was supposed to sit in tray, send requests over net periodically and notify me on changes in responses. I wanted to bind keyboard shortcut to "check right now, don't wait" action.

Posted this on ruby-forum (with more info): http://www.ruby-forum.com/topic/4406274#1078051.

Jason Thomas jmthomas closed this September 26, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.