delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/04/02/20:07:45

X-Spam-Check-By: sourceware.org
Date: Mon, 2 Apr 2007 20:07:23 -0400
From: Bob Rossi <bob_rossi AT cox DOT net>
To: cygwin AT cygwin DOT com
Subject: SIGTSTP and select
Message-ID: <20070403000723.GG24160@cox.net>
Mail-Followup-To: cygwin AT cygwin DOT com
MIME-Version: 1.0
User-Agent: Mutt/1.5.12-2006-07-14
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

Hi,

I'm preparing a new release of CGDB and I'm testing it out on several
platforms. I noticed a bug and tracked it down to SIGTSTP and select.

I'm not exactly sure what has changed since the last release to cause
this issue. However, here it is.

CGDB has a select loop that it uses as it's main loop. Since CGDB is a
ncurses application, the user can type ctrl-z and it is put into the
background. Then if the user types 'fg' it should resume like normal.

When ctrl-z is typed, CGDB receives a SIGTSTP on both linux and cygwin.
When CGDB is at the select loop and this happens on linux select returns
-1 and errno is set to EINTR. My code simple does a 'continue' when this
happens and the select loop is reentered. All works well. On cygwin,
select does not return with -1. (I didn't check the return value but I
can, I just compare to -1 in an if statement). In fact, select also
detects that input is ready on stdin. This causes CGDB to get to a read
system call (which is non blocking) and the read system call fails with
errno set to EAGAIN. This causes CGDB to exit.

The main loop looks something like this,
  if (select (max + 1, &rset, NULL, NULL, NULL) == -1)
    { 
      if (errno == EINTR)
        continue;
      ..
    }

  if (FD_ISSET (STDIN_FILENO, &rset)) {
    handle_stdin
  }

So, my question is, is there a bug with select on cygwin? Is select
working properly and I should handle the read call differently? Why does
it act differently than linux?

Sorry if this question is obvious to everyone else, it isn't to me.

Thanks,
Bob Rossi

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

- Raw text -


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