From owner-freebsd-threads@FreeBSD.ORG Wed Dec 22 06:10:24 2004 Return-Path: Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7752D16A4CF for ; Wed, 22 Dec 2004 06:10:24 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5AF2743D41 for ; Wed, 22 Dec 2004 06:10:24 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.1/8.13.1) with ESMTP id iBM6AOAk012633 for ; Wed, 22 Dec 2004 06:10:24 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.1/8.13.1/Submit) id iBM6AOuo012632; Wed, 22 Dec 2004 06:10:24 GMT (envelope-from gnats) Date: Wed, 22 Dec 2004 06:10:24 GMT Message-Id: <200412220610.iBM6AOuo012632@freefall.freebsd.org> To: freebsd-threads@FreeBSD.org From: Craig Rodrigues Subject: Re: threads/75273: FBSD 5.3 libpthread (KSE) bug X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Craig Rodrigues List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Dec 2004 06:10:24 -0000 The following reply was made to PR threads/75273; it has been noted by GNATS. From: Craig Rodrigues To: freebsd-gnats-submit@freebsd.org Cc: ixew@hotmail.com Subject: Re: threads/75273: FBSD 5.3 libpthread (KSE) bug Date: Wed, 22 Dec 2004 01:05:04 -0500 Here is the non-MIME mangled version of the demo source. It works for me on -CURRENT. #include #include #include #include #include #include #define ASSRET(cond) do { \ if (!(cond)) { \ fprintf(stderr, "ASSRET ERROR @ %d -> %s\n", __LINE__, \ strerror(ret == -1 ? errno : ret)); \ exit(EXIT_FAILURE); \ } \ } while (0) int tock; void tick() { tock = 1; } void *pulse(void *arg) { int ret; struct itimerval it; sigset_t set; sigemptyset(&set); sigaddset(&set, SIGALRM); ret = sigprocmask(SIG_BLOCK, &set, NULL); ASSRET(ret == 0); sigemptyset(&set); it.it_interval.tv_sec = 1; it.it_interval.tv_usec = 0; it.it_value.tv_sec = 1; it.it_value.tv_usec = 0; ret = setitimer(ITIMER_REAL, &it, NULL); ASSRET(ret == 0); while (1) { while (!tock) sigsuspend(&set); tock = 0; putchar('*'); fflush(stdout); } } int main() { int ret; pthread_attr_t attr; pthread_t thread; ret = pthread_attr_init(&attr); ASSRET(ret == 0); ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); ASSRET(ret == 0); signal(SIGALRM, tick); ret = pthread_create(&thread, NULL, pulse, NULL); ASSRET(ret == 0); printf("Press Enter to cancel the pulse() thread\n"); while (getchar() != '\n'); ret = pthread_cancel(thread); ASSRET(ret == 0); ret = pthread_join(thread, NULL); ASSRET(ret == 0); printf("Press Enter to end\n"); while (getchar() != '\n'); return 0; }