X-Spam-Check-By: sourceware.org Date: Mon, 13 Feb 2006 12:18:45 -0700 From: "Jerry D. Hedden" Subject: BUG: ualarm(0,0) not clearing ualarms To: cygwin AT cygwin DOT com Message-ID: <20060213121845.fb30e530d17747c2b054d625b8945d88.487b492f1c.wbe@email.secureserver.net> MIME-Version: 1.0 Content-Type: TEXT/plain; CHARSET=US-ASCII X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm 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 have encounted a bug in Cygwin whereby ualarm(0,0) is not clearing previously set ualarms. This first cropped up while using Perl, but I was able to reproduce the bug with the following 'C' program. The gist is that ualarm() is used several times, and then a final ualarm(0,0) is executed to clear them. This is followed by a usleep(). The alarm signal handler shows that 'bogus' alarms are going off during the usleep(). Without the signal handler, the program would terminate prematurely due to uncaught SIGALRM. /* * Reproduces bug associated with ualarm * * Make using: gcc -o ualarm_bug.exe ualarm_bug.c * * Typical output: * * First ualarm - one shot * Second ualarm - one shot * Last ualarm - repeats 3 times * Clearing ualarm * Sleeping * --- BOGUS ALARM --- * --- BOGUS ALARM --- * Done * */ #include #include /* Increments a counter when alarm goes off */ int tick; void inc_tick(int signal) { tick++; } /* Prints out a warning message when an alarm goes off */ void bogus(int signal) { printf("--- BOGUS ALARM ---\n"); } int main(int argc, char **argv) { int counter; /* Set incrementing alarm handler */ signal(SIGALRM, &inc_tick); printf("First ualarm - one shot\n"); tick = 0; ualarm(10000, 0); while (tick == 0) { counter++; }; printf("Second ualarm - one shot\n"); tick = 0; ualarm(10000, 0); while (tick == 0) { counter++; }; printf("Last ualarm - repeats 3 times\n"); tick = 0; ualarm(10000, 10000); while (tick < 3) { counter++; }; printf("Clearing ualarm\n"); ualarm(0, 0); /* Set warning alarm handler */ signal(SIGALRM, &bogus); printf("Sleeping\n"); usleep(500000); printf("Done\n"); exit(0); } /* EOF */ -- 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/