summaryrefslogtreecommitdiff
path: root/nptl
diff options
context:
space:
mode:
Diffstat (limited to 'nptl')
-rw-r--r--nptl/allocatestack.c20
-rw-r--r--nptl/descr.h4
-rw-r--r--nptl/nptl-init.c15
-rw-r--r--nptl/pthread_cancel.c18
-rw-r--r--nptl/pthread_getattr_np.c1
5 files changed, 11 insertions, 47 deletions
diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
index 3016a2ed5c..98a0ea2862 100644
--- a/nptl/allocatestack.c
+++ b/nptl/allocatestack.c
@@ -438,9 +438,6 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
SETUP_THREAD_SYSINFO (pd);
#endif
- /* The process ID is also the same as that of the caller. */
- pd->pid = THREAD_GETMEM (THREAD_SELF, pid);
-
/* Don't allow setxid until cloned. */
pd->setxid_futex = -1;
@@ -577,9 +574,6 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
/* Don't allow setxid until cloned. */
pd->setxid_futex = -1;
- /* The process ID is also the same as that of the caller. */
- pd->pid = THREAD_GETMEM (THREAD_SELF, pid);
-
/* Allocate the DTV for this thread. */
if (_dl_allocate_tls (TLS_TPADJ (pd)) == NULL)
{
@@ -873,9 +867,6 @@ __reclaim_stacks (void)
/* This marks the stack as free. */
curp->tid = 0;
- /* The PID field must be initialized for the new process. */
- curp->pid = self->pid;
-
/* Account for the size of the stack. */
stack_cache_actsize += curp->stackblock_size;
@@ -901,13 +892,6 @@ __reclaim_stacks (void)
}
}
- /* Reset the PIDs in any cached stacks. */
- list_for_each (runp, &stack_cache)
- {
- struct pthread *curp = list_entry (runp, struct pthread, list);
- curp->pid = self->pid;
- }
-
/* Add the stack of all running threads to the cache. */
list_splice (&stack_used, &stack_cache);
@@ -1052,9 +1036,9 @@ setxid_signal_thread (struct xid_command *cmdp, struct pthread *t)
return 0;
int val;
+ pid_t pid = __getpid ();
INTERNAL_SYSCALL_DECL (err);
- val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
- t->tid, SIGSETXID);
+ val = INTERNAL_SYSCALL_CALL (tgkill, err, pid, t->tid, SIGSETXID);
/* If this failed, it must have had not started yet or else exited. */
if (!INTERNAL_SYSCALL_ERROR_P (val, err))
diff --git a/nptl/descr.h b/nptl/descr.h
index 8e4938deb5..bc92abf010 100644
--- a/nptl/descr.h
+++ b/nptl/descr.h
@@ -167,8 +167,8 @@ struct pthread
therefore stack) used' flag. */
pid_t tid;
- /* Process ID - thread group ID in kernel speak. */
- pid_t pid;
+ /* Ununsed. */
+ pid_t pid_ununsed;
/* List of robust mutexes the thread is holding. */
#ifdef __PTHREAD_MUTEX_HAVE_PREV
diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
index bdbdfedcef..48fab50c4e 100644
--- a/nptl/nptl-init.c
+++ b/nptl/nptl-init.c
@@ -184,18 +184,12 @@ __nptl_set_robust (struct pthread *self)
static void
sigcancel_handler (int sig, siginfo_t *si, void *ctx)
{
- /* Determine the process ID. It might be negative if the thread is
- in the middle of a fork() call. */
- pid_t pid = THREAD_GETMEM (THREAD_SELF, pid);
- if (__glibc_unlikely (pid < 0))
- pid = -pid;
-
/* Safety check. It would be possible to call this function for
other signals and send a signal from another process. This is not
correct and might even be a security problem. Try to catch as
many incorrect invocations as possible. */
if (sig != SIGCANCEL
- || si->si_pid != pid
+ || si->si_pid != __getpid()
|| si->si_code != SI_TKILL)
return;
@@ -243,19 +237,14 @@ struct xid_command *__xidcmd attribute_hidden;
static void
sighandler_setxid (int sig, siginfo_t *si, void *ctx)
{
- /* Determine the process ID. It might be negative if the thread is
- in the middle of a fork() call. */
- pid_t pid = THREAD_GETMEM (THREAD_SELF, pid);
int result;
- if (__glibc_unlikely (pid < 0))
- pid = -pid;
/* Safety check. It would be possible to call this function for
other signals and send a signal from another process. This is not
correct and might even be a security problem. Try to catch as
many incorrect invocations as possible. */
if (sig != SIGSETXID
- || si->si_pid != pid
+ || si->si_pid != __getpid ()
|| si->si_code != SI_TKILL)
return;
diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c
index 1419baf988..89d02e1741 100644
--- a/nptl/pthread_cancel.c
+++ b/nptl/pthread_cancel.c
@@ -22,7 +22,7 @@
#include "pthreadP.h"
#include <atomic.h>
#include <sysdep.h>
-
+#include <unistd.h>
int
pthread_cancel (pthread_t th)
@@ -66,19 +66,11 @@ pthread_cancel (pthread_t th)
#ifdef SIGCANCEL
/* The cancellation handler will take care of marking the
thread as canceled. */
- INTERNAL_SYSCALL_DECL (err);
-
- /* One comment: The PID field in the TCB can temporarily be
- changed (in fork). But this must not affect this code
- here. Since this function would have to be called while
- the thread is executing fork, it would have to happen in
- a signal handler. But this is no allowed, pthread_cancel
- is not guaranteed to be async-safe. */
- int val;
- val = INTERNAL_SYSCALL (tgkill, err, 3,
- THREAD_GETMEM (THREAD_SELF, pid), pd->tid,
- SIGCANCEL);
+ pid_t pid = getpid ();
+ INTERNAL_SYSCALL_DECL (err);
+ int val = INTERNAL_SYSCALL_CALL (tgkill, err, pid, pd->tid,
+ SIGCANCEL);
if (INTERNAL_SYSCALL_ERROR_P (val, err))
result = INTERNAL_SYSCALL_ERRNO (val, err);
#else
diff --git a/nptl/pthread_getattr_np.c b/nptl/pthread_getattr_np.c
index fb906f0484..32d7484bf8 100644
--- a/nptl/pthread_getattr_np.c
+++ b/nptl/pthread_getattr_np.c
@@ -68,7 +68,6 @@ pthread_getattr_np (pthread_t thread_id, pthread_attr_t *attr)
{
/* No stack information available. This must be for the initial
thread. Get the info in some magical way. */
- assert (abs (thread->pid) == thread->tid);
/* Stack size limit. */
struct rlimit rl;