Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 04 Aug 2010 10:36:24 -0400
From:      Andrew Gallatin <gallatin@cs.duke.edu>
To:        current@freebsd.org
Subject:   Incorrect cv_wait_sig() return values?
Message-ID:  <4C597AE8.5090703@cs.duke.edu>

next in thread | raw e-mail | index | archive | help
Hi,

I recently noticed that cv_wait_sig() will return -1
rather than EINTR when a SIGINT is delivered.  This is
in contrast to CONDVAR(9) which states:

<...>
       cv_wait_sig() and cv_timedwait_sig() return prematurely with a
       value of EINTR or ERESTART if a signal is caught
<...>

To demonstrate the problem outside my out-of-tree driver, I
took the skeleton driver from
http://www.captain.at/programming/freebsd/
and added the following function, invoked at module
load:

static struct mtx m;
static struct cv c;

static void
cv_test(void)
{
         int rc;

         mtx_init(&m, "skel_m", MTX_DEF, MTX_DEF);
         cv_init(&c, "skel_c");
         mtx_lock(&m);
         rc = cv_wait_sig(&c, &m);
         mtx_unlock(&m);
         printf("cv_wait_sig returned %d\n", rc);
         cv_destroy(&c);
         mtx_destroy(&m);
}


I load the module, and I ^C kldload after a few seconds
to break out of the cv_wait_sig(), which results in this
output on console:

	Skeleton KLD loaded.
	cv_wait_sig returned -1

Am I doing something wrong, or are condvars broken?
I've tried to track this down with dtrace, but failed..

Thanks,

Drew




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C597AE8.5090703>