Subject: lib/34931: PTHREAD_ATTR(3) doesn't document PTHREAD_CREATE_JOINABLE and PTHREAD_CREATE_DETACHED macros
To: None <lib-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <mm_lists@pulsar-zone.net>
List: netbsd-bugs
Date: 10/28/2006 04:55:00
>Number:         34931
>Category:       lib
>Synopsis:       PTHREAD_ATTR(3) doesn't document PTHREAD_CREATE_JOINABLE and PTHREAD_CREATE_DETACHED macros
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 28 04:55:00 +0000 2006
>Originator:     Matthew Mondor
>Release:        recent netbsd-3 branch
>Organization:
Pulsar-Zone Reg.
>Environment:
NetBSD hal.xisop 3.1_RC4 NetBSD 3.1_RC4 (GENERIC_MM) #3: Fri Oct 13 18:55:35 EDT 2006  root@hal.xisop:/usr/src/sys/arch/i386/compile/GENERIC_MM i386
>Description:
The PTHREAD_ATTR(3) manual page should document the PTHREAD_CREATE_JOINABLE and PTHREAD_CREATE_DETACHED macros.
>How-To-Repeat:
man 3 pthread_attr

:)
>Fix:
Apply the following diff to pthread_attr.3:

--- /usr/share/man/man3/pthread_attr.3  2005-12-24 02:48:54.000000000 -0500
+++ pthread_attr.3      2006-10-28 00:52:09.000000000 -0400
@@ -142,6 +142,22 @@
 .Fn pthread_attr_get*
 functions copy the value of the attribute that corresponds to each function name
 to the location pointed to by the second function parameter.
+.Pp
+The attribute parameters for the
+.Fn pthread_attr_setdetachstate
+and
+.Fn pthread_attr_getdetachstate
+are mutually exclusive and must be one of:
+.Bl -tag -width xxxxxxxx
+.It PTHREAD_CREATE_JOINABLE
+The threads must explicitely be waited for using the
+.Fn pthread_join
+function once they exit for their status to be received and their resources
+to be freed.  This is the default.
+.It PTHREAD_CREATE_DETACHED
+The thread's resources will automatically be freed once the thread exits,
+and the thread will not be joined.
+.El
 .Sh RETURN VALUES
 If successful, these functions return 0.
 Otherwise, an error number is returned to indicate the error.
@@ -223,7 +239,8 @@
 .\" .Fa contentionscope .
 .\" .El
 .Sh SEE ALSO
-.Xr pthread_create 3
+.Xr pthread_create 3 ,
+.Xr pthread_join 3
 .Sh STANDARDS
 .Fn pthread_attr_init ,
 .Fn pthread_attr_destroy ,