delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/10/20/08:14:23

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_NEUTRAL
X-Spam-Check-By: sourceware.org
Message-ID: <4EA01079.5010303@cornell.edu>
Date: Thu, 20 Oct 2011 08:13:45 -0400
From: Ken Brown <kbrown AT cornell DOT edu>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Question about Cygwin's select()
References: <4E9ED08B DOT 3080503 AT cornell DOT edu> <20111019144910 DOT GB16351 AT calimero DOT vinschen DOT de> <20111019162219 DOT GB1085 AT ednor DOT casa DOT cgf DOT cx> <4E9F09AE DOT 7090609 AT cornell DOT edu> <4E9F2FE1 DOT 7050003 AT cornell DOT edu>
In-Reply-To: <4E9F2FE1.7050003@cornell.edu>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On 10/19/2011 4:15 PM, Ken Brown wrote:
> I don't have a testcase yet, but I have a clearer idea of what's
> happening. It actually has nothing to do with the gdb subprocess, but
> rather is a problem that can occur whenever emacs is running its main
> command loop. emacs polls for keyboard input while also using select to
> check for output from subprocesses. It's in this setting that select
> often fails with EINTR, even when there are no subprocesses running. I
> wonder if the keyboard polling is doing something that interrupts the
> select call.

I think this guess is correct.  If I start up emacs and do nothing, 
strace shows many sequences like the following:

  - emacs calls select
  - a timer sends SIGALRM
  - select returns -1 with error EINTR

The EINTR isn't actually visible in the strace output, but I do see 
"select_stuff::wait: signal received".  A glance at select.cc indicates 
that this is the debug output produced by select when it is about to 
return -1 with EINTR.

These sequences always occur in connection with start_thread_socket. 
I've appended a typical excerpt from the strace output below.  Please 
let me know if you need to see more strace output.  I didn't want to 
spam the list by sending too much.

You still might need more information, but I can at least refine my 
original question:  Is it reasonable that select should give up and 
return -1 because a timer has sent SIGALRM?

Ken

[...]
   686 8226742 [main] emacs 6772 cygwin_select: 6, 0x28C134, 0x28C12C, 
0x0, 0x28C200
[...]
   106 8227514 [main] emacs 6772 select_stuff::wait: m 4, ms 464
    49 8227563 [select_socket] emacs 6772 thread_socket: stuff_start 
0x28C098
    53 8227616 [select_socket] emacs 6772 peek_socket: read_ready: 0, 
write_ready: 0, except_ready: 0
  2501 8230117 [itimer] emacs 6772 timer_thread: timed out
    66 8230183 [itimer] emacs 6772 timer_thread: 0x6118D560 sending sig 14
    52 8230235 [itimer] emacs 6772 sig_send: sendsig 0x104, pid 6772, 
signal 14, its_me 1
    52 8230287 [itimer] emacs 6772 sig_send: Not waiting for 
sigcomplete.  its_me 1 signal 14
     5 8230292 [sig] emacs 6772 sigpacket::process: signal 14 processing
    35 8230327 [itimer] emacs 6772 sig_send: returning 0x0 from sending 
signal 14
    28 8230355 [sig] emacs 6772 _cygtls::find_tls: sig 14
    61 8230416 [sig] emacs 6772 sigpacket::process: signal 14, about to 
call 0x5E85A8
    37 8230453 [sig] emacs 6772 setup_handler: controlled interrupt. 
stackptr 0x28DA34, stack 0x28DA30, stackptr[-1] 0x4F2F4C
[...]
    35 8230632 [sig] emacs 6772 _cygtls::interrupt_setup: armed 
signal_arrived 0x154, sig 14, res 1
    57 8230689 [sig] emacs 6772 setup_handler: signal 14 delivered
    40 8230729 [sig] emacs 6772 sigpacket::process: returning 1
    51 8230780 [main] emacs 6772 select_stuff::cleanup: calling cleanup 
routines
   596 8231376 [main] emacs 6772 socket_cleanup: si 0x8016D220 
si->thread 0x611773F0
   307 8231683 [select_socket] emacs 6772 thread_socket: leaving 
thread_socket
   696 8232379 [main] emacs 6772 socket_cleanup: returning
    56 8232435 [main] emacs 6772 select_stuff::wait: signal received




--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019