Date: Wed, 4 Aug 2010 19:04:04 +0300 From: Kostik Belousov <kostikbel@gmail.com> To: Andrew Gallatin <gallatin@cs.duke.edu> Cc: current@freebsd.org Subject: Re: Incorrect cv_wait_sig() return values? Message-ID: <20100804160404.GZ22295@deviant.kiev.zoral.com.ua> In-Reply-To: <20100804154604.GY22295@deviant.kiev.zoral.com.ua> References: <4C597AE8.5090703@cs.duke.edu> <20100804154604.GY22295@deviant.kiev.zoral.com.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
--ttdIJ16FdHy9Oveo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Aug 04, 2010 at 06:46:04PM +0300, Kostik Belousov wrote: > On Wed, Aug 04, 2010 at 10:36:24AM -0400, Andrew Gallatin wrote: > > Hi, > >=20 > > 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: > >=20 > > <...> > > cv_wait_sig() and cv_timedwait_sig() return prematurely with a > > value of EINTR or ERESTART if a signal is caught > > <...> > >=20 > > 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: > >=20 > > static struct mtx m; > > static struct cv c; > >=20 > > static void > > cv_test(void) > > { > > int rc; > >=20 > > mtx_init(&m, "skel_m", MTX_DEF, MTX_DEF); > > cv_init(&c, "skel_c"); > > mtx_lock(&m); > > rc =3D cv_wait_sig(&c, &m); > > mtx_unlock(&m); > > printf("cv_wait_sig returned %d\n", rc); > > cv_destroy(&c); > > mtx_destroy(&m); > > } > >=20 > >=20 > > 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: > >=20 > > Skeleton KLD loaded. > > cv_wait_sig returned -1 > >=20 > > Am I doing something wrong, or are condvars broken? > > I've tried to track this down with dtrace, but failed.. >=20 > What version of the system do you use ? I cannot confirm this on > the HEAD from several hours ago with the following test module. > On the SIGINT I get `4' printed, which is EINTR. BTW, -1 is ERESTART, so if you have SIGINT catched with SA_RESTART flag in the process that initiated kldload(2) syscall, then -1 is the right return code for cv_wait_sig. --ttdIJ16FdHy9Oveo Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkxZj3QACgkQC3+MBN1Mb4irxQCdGqUdhzGbjYTsFgG0fyd1Nt6M s3QAn29/2ijqRbtad2o2+2Z9qXcRnjBx =G6JT -----END PGP SIGNATURE----- --ttdIJ16FdHy9Oveo--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100804160404.GZ22295>