X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_33,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: Waldemar Rachwal Subject: sigwait() and "sticky" signals (SIGWINCH...) in Cygwin 1.7 Date: Wed, 26 Aug 2009 20:13:37 +0000 (UTC) Lines: 91 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: Loom/3.14 (http://gmane.org/) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com I observe strange behavior of sigwait() with SIGWINCH signal (and possibly others... like SIGCHLD). Look at a short program below. In a loop I wait for SIG{INT,WINCH} signals. SIGWINCH, similarly to SIGCHLD is ignored by default, so I had to register a dummy signal handler for it. When the program (compiled with gcc-4) is running, SIGWINCH is never returned by the sigwait() immediately after window's resize, but always along with successive SIGINT when I press Ctrl+C. Regards, Waldemar. My system is: $ uname -a CYGWIN_NT-6.0 wrachwal-PC 1.7.0(0.212/5/3) 2009-08-20 10:56 i686 Cygwin running at rxvt + zsh #################### /* sigwait.c -- trying sigwait with various signals */ #include #include #include // strerror() #include // exit() #include #include /*==========================================================================*/ static void winch_signal_handler (int sig) { static const char* msg = "!!! winch_signal_handler: unexpected call\n"; /* async-signal safe "print" */ ssize_t dont_care = write(/*stdout*/1, msg, sizeof(msg) - 1); dont_care = dont_care; } /****************************************************************************/ int main () { sigset_t ss; struct sigaction sa; int error; int status; int sigint_count = 0; sigemptyset(&ss); sigaddset(&ss, SIGWINCH); sigaddset(&ss, SIGINT); error = pthread_sigmask(SIG_BLOCK, &ss, NULL); assert(0 == error); sa.sa_flags = 0; sa.sa_handler = &winch_signal_handler; sigemptyset(&sa.sa_mask); status = sigaction(SIGWINCH, &sa, NULL); assert(-1 != status); printf("# entering sigwait() loop...\n"); while (1) { int signo; error = sigwait(&ss, &signo); if (error == 0) { if (signo == SIGWINCH) { printf("Got SIGWINCH\n"); } else if (signo == SIGINT) { ++sigint_count; printf("Got SIGINT (#%d)\n", sigint_count); if (sigint_count == 5) { printf("End.\n"); exit(0); } } } else { printf("sigwait: %s\n", strerror(error)); } } } -- 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