2008-10-26 04:44:51 +00:00
|
|
|
.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
|
|
|
|
.\" <mtk.manpages@gmail.com>
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
|
|
.\" preserved on all copies.
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
|
|
.\" permission notice identical to this one.
|
|
|
|
.\"
|
|
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
|
|
.\" have taken the same level of care in the production of this manual,
|
|
|
|
.\" which is licensed free of charge, as they might when working
|
|
|
|
.\" professionally.
|
|
|
|
.\"
|
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
|
|
|
.\"
|
accept.2, clone.2, dup.2, fallocate.2, pipe.2, readahead.2, sched_setaffinity.2, unshare.2, CPU_SET.3, endian.3, euidaccess.3, fexecve.3, getpt.3, getpw.3, getumask.3, getutmp.3, gnu_get_libc_version.3, makedev.3, matherr.3, mbsnrtowcs.3, memfrob.3, pthread_attr_setaffinity_np.3, pthread_getattr_np.3, pthread_setaffinity_np.3, pthread_tryjoin_np.3, tcgetsid.3, wcscasecmp.3, wcsncasecmp.3, wcsnlen.3, wcsnrtombs.3, wcswidth.3, rtld-audit.7: SYNOPSIS: Add reference to feature_test_macros(7)
These pages specify feature test macros in the function
prototypes. Add a reference to feature_test_macros(7),
so that readers are pointed to the information that
feature test macros must be defined before including
*any* header file.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-10 05:06:22 +00:00
|
|
|
.TH PTHREAD_TRYJOIN_NP 3 2010-09-10 "Linux" "Linux Programmer's Manual"
|
2008-10-26 04:44:51 +00:00
|
|
|
.SH NAME
|
|
|
|
pthread_tryjoin_np, pthread_timedjoin_np \- try to join with a
|
|
|
|
terminated thread
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.nf
|
accept.2, clone.2, dup.2, fallocate.2, pipe.2, readahead.2, sched_setaffinity.2, unshare.2, CPU_SET.3, endian.3, euidaccess.3, fexecve.3, getpt.3, getpw.3, getumask.3, getutmp.3, gnu_get_libc_version.3, makedev.3, matherr.3, mbsnrtowcs.3, memfrob.3, pthread_attr_setaffinity_np.3, pthread_getattr_np.3, pthread_setaffinity_np.3, pthread_tryjoin_np.3, tcgetsid.3, wcscasecmp.3, wcsncasecmp.3, wcsnlen.3, wcsnrtombs.3, wcswidth.3, rtld-audit.7: SYNOPSIS: Add reference to feature_test_macros(7)
These pages specify feature test macros in the function
prototypes. Add a reference to feature_test_macros(7),
so that readers are pointed to the information that
feature test macros must be defined before including
*any* header file.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-10 05:06:22 +00:00
|
|
|
.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
|
2008-10-26 04:44:51 +00:00
|
|
|
.B #include <pthread.h>
|
|
|
|
|
|
|
|
.BI "int pthread_tryjoin_np(pthread_t " thread ", void **" retval );
|
|
|
|
|
|
|
|
.BI "int pthread_timedjoin_np(pthread_t " thread ", void **" retval ,
|
2008-11-04 14:00:41 +00:00
|
|
|
.BI " const struct timespec *" abstime );
|
2008-10-26 04:44:51 +00:00
|
|
|
.fi
|
|
|
|
.sp
|
|
|
|
Compile and link with \fI\-pthread\fP.
|
|
|
|
.SH DESCRIPTION
|
|
|
|
These functions operate in the same way as
|
|
|
|
.BR pthread_join (3),
|
|
|
|
except for the differences described on this page.
|
|
|
|
|
|
|
|
The
|
|
|
|
.BR pthread_tryjoin_np ()
|
accept.2, connect.2, eventfd.2, flock.2, open.2, posix_fadvise.2, read.2, recv.2, sched_setscheduler.2, select_tut.2, send.2, signalfd.2, splice.2, timerfd_create.2, write.2, flockfile.3, mkfifo.3, mq_notify.3, mq_open.3, pthread_tryjoin_np.3, scanf.3, random.4, ddp.7, epoll.7, fifo.7, ip.7, pipe.7, socket.7, spufs.7: Global fix: s/non-blocking/nonblocking/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 16:43:10 +00:00
|
|
|
function performs a nonblocking join with the thread
|
2008-10-26 04:44:51 +00:00
|
|
|
.IR thread ,
|
|
|
|
returning the exit status of the thread in
|
|
|
|
.IR *retval .
|
|
|
|
If
|
|
|
|
.I thread
|
|
|
|
has not yet terminated, then instead of blocking, as is done by
|
|
|
|
.BR pthread_join (3),
|
|
|
|
the call returns an error.
|
|
|
|
|
|
|
|
The
|
|
|
|
.BR pthread_timedjoin_np ()
|
|
|
|
function performs a join-with-timeout.
|
|
|
|
If
|
|
|
|
.I thread
|
|
|
|
has not yet terminated,
|
|
|
|
then the call blocks until a maximum time, specified in
|
|
|
|
.IR abstime .
|
|
|
|
If the timeout expires before
|
|
|
|
.I thread
|
|
|
|
terminates,
|
|
|
|
the call returns an error.
|
|
|
|
The
|
|
|
|
.I abstime
|
|
|
|
argument is a structure of the following form,
|
|
|
|
specifying an absolute time measured since the Epoch (see
|
|
|
|
.BR time (2)):
|
|
|
|
|
|
|
|
.in +4n
|
|
|
|
.nf
|
|
|
|
struct timespec {
|
|
|
|
time_t tv_sec; /* seconds */
|
|
|
|
long tv_nsec; /* nanoseconds */
|
|
|
|
};
|
|
|
|
.fi
|
|
|
|
.in
|
|
|
|
.SH RETURN VALUE
|
|
|
|
On success,
|
|
|
|
these functions return 0;
|
|
|
|
on error, they return an error number.
|
|
|
|
.SH ERRORS
|
|
|
|
These functions can fail with the same errors as
|
|
|
|
.BR pthread_join (3).
|
|
|
|
.BR pthread_tryjoin_np ()
|
|
|
|
can in addition fail with the following error:
|
|
|
|
.TP
|
|
|
|
.B EBUSY
|
|
|
|
.I thread
|
|
|
|
had not yet terminated at the time of the call.
|
|
|
|
.PP
|
|
|
|
.BR pthread_timedjoin_np ()
|
|
|
|
can in addition fail with the following error:
|
|
|
|
.TP
|
|
|
|
.BR ETIMEDOUT
|
|
|
|
The call timed out before
|
|
|
|
.I thread
|
|
|
|
terminated.
|
|
|
|
.PP
|
|
|
|
.BR pthread_timedjoin_np ()
|
|
|
|
never returns the error
|
|
|
|
.BR EINTR .
|
|
|
|
.SH VERSIONS
|
|
|
|
These functions first appeared in glibc in version 2.3.3.
|
|
|
|
.SH CONFORMING TO
|
accept.2, execve.2, futimesat.2, getresuid.2, getrlimit.2, madvise.2, mq_getsetattr.2, msgctl.2, nice.2, open.2, poll.2, setresuid.2, shmctl.2, sigaction.2, times.2, utimensat.2, __setfpucw.3, atoi.3, endian.3, err.3, euidaccess.3, fenv.3, fopencookie.3, fpurge.3, getgrouplist.3, getutmp.3, j0.3, lgamma.3, netlink.3, pthread_attr_init.3, pthread_attr_setaffinity_np.3, pthread_cleanup_push_defer_np.3, pthread_getattr_np.3, pthread_kill_other_threads_np.3, pthread_setaffinity_np.3, pthread_tryjoin_np.3, pthread_yield.3, random_r.3, readdir.3, rtnetlink.3, scanf.3, setenv.3, significand.3, sigsetops.3, strerror.3, strstr.3, sysv_signal.3, termios.3, timegm.3, unlocked_stdio.3, y0.3, locale.5, bootparam.7, feature_test_macros.7, ip.7, locale.7, pthreads.7, rtld-audit.7, nscd.8: Global fix: s/non-standard/nonstandard/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 16:37:52 +00:00
|
|
|
These functions are nonstandard GNU extensions;
|
execve.2, fallocate.2, futex.2, sched_rr_get_interval.2, select_tut.2, shmget.2, timer_getoverrun.2, times.2, pthread_attr_init.3, pthread_attr_setaffinity_np.3, pthread_cleanup_push_defer_np.3, pthread_getattr_np.3, pthread_self.3, pthread_setaffinity_np.3, pthread_tryjoin_np.3, sem_open.3, stdin.3, rtc.4, tty_ioctl.4, unix.7: Global fix: s/non-portable/nonportable/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 16:46:09 +00:00
|
|
|
hence the suffix "_np" (nonportable) in the names.
|
2008-10-26 04:44:51 +00:00
|
|
|
.SH EXAMPLE
|
|
|
|
The following code waits to join for up to 5 seconds:
|
|
|
|
|
|
|
|
.nf
|
|
|
|
struct timespec ts;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
...
|
|
|
|
|
2008-11-11 13:33:43 +00:00
|
|
|
if (clock_gettime(CLOCK_REALTIME, &ts) == \-1) {
|
|
|
|
/* Handle error */
|
|
|
|
}
|
2008-10-26 04:44:51 +00:00
|
|
|
|
|
|
|
ts.tv_sec += 5;
|
|
|
|
|
|
|
|
s = pthread_timedjoin_np(thread, NULL, &ts);
|
|
|
|
if (s != 0) {
|
|
|
|
/* Handle error */
|
|
|
|
}
|
|
|
|
.fi
|
|
|
|
.SH SEE ALSO
|
clock_nanosleep.2, getrusage.2, timerfd_create.2, clock.3, clock_getcpuclockid.3, ftime.3, pthread_create.3, pthread_getcpuclockid.3, pthread_tryjoin_np.3, sem_wait.3, time.7: Global fix: Fix xrefs to clock_*.? pages to reflect move to section 2
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2009-02-07 21:10:39 +00:00
|
|
|
.BR clock_gettime (2),
|
2008-10-26 04:44:51 +00:00
|
|
|
.BR pthread_exit (3),
|
clock_nanosleep.2, getpriority.2, kexec_load.2, nanosleep.2, nice.2, sched_setaffinity.2, timer_create.2, timer_delete.2, timer_settime.2, utime.2, btowc.3, futimes.3, log.3, pthread_attr_setguardsize.3, pthread_kill_other_threads_np.3, pthread_setaffinity_np.3, pthread_setcancelstate.3, pthread_setschedparam.3, pthread_setschedprio.3, pthread_tryjoin_np.3, strcoll.3, strcpy.3, string.3, strxfrm.3, networks.5, aio.7, sigevent.7, udplite.7: SEE ALSO: Place entries in correct order
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-11-01 05:34:26 +00:00
|
|
|
.BR pthread_join (3),
|
2008-10-26 04:44:51 +00:00
|
|
|
.BR pthreads (7)
|