From owner-freebsd-standards@FreeBSD.ORG Tue Feb 22 21:42:01 2011 Return-Path: Delivered-To: standards@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 04F44106564A; Tue, 22 Feb 2011 21:42:01 +0000 (UTC) (envelope-from brucec@freebsd.org) Received: from muon.cran.org.uk (unknown [IPv6:2a01:348:0:15:5d59:5c40:0:1]) by mx1.freebsd.org (Postfix) with ESMTP id 906088FC14; Tue, 22 Feb 2011 21:42:00 +0000 (UTC) Received: from muon.cran.org.uk (localhost [127.0.0.1]) by muon.cran.org.uk (Postfix) with ESMTP id C65A6E8BA7; Tue, 22 Feb 2011 21:41:57 +0000 (GMT) Received: from core.nessbank (client-86-31-236-253.oxfd.adsl.virginmedia.com [86.31.236.253]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by muon.cran.org.uk (Postfix) with ESMTPSA id A86DDE8838; Tue, 22 Feb 2011 21:41:57 +0000 (GMT) From: Bruce Cran To: bug-followup@freebsd.org, dan@obluda.cz, standards@freebsd.org Date: Tue, 22 Feb 2011 21:41:54 +0000 User-Agent: KMail/1.13.5 (FreeBSD/9.0-CURRENT; KDE/4.5.5; amd64; ; ) MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_i2CZNPTu+b2EAx0" Message-Id: <201102222141.54428.brucec@freebsd.org> Cc: Subject: Re: docs/125751: man 3 pthread_getschedparam section ERRORS incomplete X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Feb 2011 21:42:01 -0000 --Boundary-00=_i2CZNPTu+b2EAx0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit According to POSIX EINVAL isn't a valid return value, which is why it's not documented. It appears that if the parameters are NULL 0 is expected to be returned; in glibc on Linux if both are NULL then 0 is returned otherwise if just one is NULL then a segfault occurs. I'd like to commit the attached patch which I think brings the implementation more in-line with POSIX: return 0 if either parameters are NULL and return ESRCH from functions which search for a pthread_t if a thread doesn't exist regardless of whether it's NULL or otherwise. -- Bruce Cran --Boundary-00=_i2CZNPTu+b2EAx0 Content-Type: text/x-patch; charset="ISO-8859-1"; name="pthread.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pthread.diff" Index: thr_list.c =================================================================== --- thr_list.c (revision 218951) +++ thr_list.c (working copy) @@ -283,7 +283,7 @@ if (thread == NULL) /* Invalid thread: */ - return (EINVAL); + return (ESRCH); if ((ret = _thr_find_thread(curthread, thread, include_dead)) == 0) { thread->refcount++; @@ -334,7 +334,7 @@ int ret; if (thread == NULL) - return (EINVAL); + return (ESRCH); ret = 0; THREAD_LIST_RDLOCK(curthread); Index: thr_getschedparam.c =================================================================== --- thr_getschedparam.c (revision 218951) +++ thr_getschedparam.c (working copy) @@ -51,7 +51,7 @@ int ret; if (policy == NULL || param == NULL) - return (EINVAL); + return (0); if (pthread == curthread) { /* --Boundary-00=_i2CZNPTu+b2EAx0--