OSDN Git Service

(split) LDP: Update original to LDP v3.38.
[linuxjm/LDP_man-pages.git] / original / man3 / pthread_self.3
1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .TH PTHREAD_SELF 3 2008-10-24 "Linux" "Linux Programmer's Manual"
25 .SH NAME
26 pthread_self \- obtain ID of the calling thread
27 .SH SYNOPSIS
28 .nf
29 .B #include <pthread.h>
30
31 .B pthread_t pthread_self(void);
32 .sp
33 Compile and link with \fI\-pthread\fP.
34 .fi
35 .SH DESCRIPTION
36 The
37 .BR pthread_self ()
38 function returns the ID of the calling thread.
39 This is the same value that is returned in
40 .IR *thread
41 in the
42 .BR pthread_create (3)
43 call that created this thread.
44 .SH RETURN VALUE
45 This function always succeeds, returning the calling thread's ID.
46 .SH ERRORS
47 This function always succeeds.
48 .SH CONFORMING TO
49 POSIX.1-2001.
50 .SH NOTES
51 POSIX.1 allows an implementation wide freedom in choosing
52 the type used to represent a thread ID;
53 for example, representation using either an arithmetic type or
54 a structure is permitted.
55 Therefore, variables of type
56 .I pthread_t
57 can't portably be compared using the C equality operator (\fB==\fP);
58 use
59 .BR pthread_equal (3)
60 instead.
61
62 Thread identifiers should be considered opaque:
63 any attempt to use a thread ID other than in pthreads calls
64 is nonportable and can lead to unspecified results.
65
66 Thread IDs are only guaranteed to be unique within a process.
67 A thread ID may be reused after a terminated thread has been joined,
68 or a detached thread has terminated.
69
70 The thread ID returned by
71 .BR pthread_self ()
72 is not the same thing as the kernel thread ID returned by a call to
73 .BR gettid (2).
74 .SH SEE ALSO
75 .BR pthread_create (3),
76 .BR pthread_equal (3),
77 .BR pthreads (7)