From: Ulrich Drepper One more overlooked area where the thread group ID has to be used. Compile and run the following code. The program should always exit with value zero, but currently it doesn't if a parameter is passed (i.e., if the semaphore is modified in a thread other than the main one). 25-akpm/ipc/msg.c | 4 ++-- 25-akpm/ipc/sem.c | 8 ++++---- 25-akpm/ipc/shm.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff -puN ipc/msg.c~ipc-use-tgid ipc/msg.c --- 25/ipc/msg.c~ipc-use-tgid Thu Aug 28 11:55:27 2003 +++ 25-akpm/ipc/msg.c Thu Aug 28 11:55:27 2003 @@ -707,7 +707,7 @@ retry: goto retry; } - msq->q_lspid = current->pid; + msq->q_lspid = current->tgid; msq->q_stime = get_seconds(); if(!pipelined_send(msq,msg)) { @@ -801,7 +801,7 @@ retry: list_del(&msg->m_list); msq->q_qnum--; msq->q_rtime = get_seconds(); - msq->q_lrpid = current->pid; + msq->q_lrpid = current->tgid; msq->q_cbytes -= msg->m_ts; atomic_sub(msg->m_ts,&msg_bytes); atomic_dec(&msg_hdrs); diff -puN ipc/sem.c~ipc-use-tgid ipc/sem.c --- 25/ipc/sem.c~ipc-use-tgid Thu Aug 28 11:55:27 2003 +++ 25-akpm/ipc/sem.c Thu Aug 28 11:55:27 2003 @@ -664,7 +664,7 @@ static int semctl_main(int semid, int se for (un = sma->undo; un; un = un->id_next) un->semadj[semnum] = 0; curr->semval = val; - curr->sempid = current->pid; + curr->sempid = current->tgid; sma->sem_ctime = get_seconds(); /* maybe some queued-up processes were waiting for this */ update_queue(sma); @@ -1052,7 +1052,7 @@ retry_undos: if (error) goto out_unlock_free; - error = try_atomic_semop (sma, sops, nsops, un, current->pid); + error = try_atomic_semop (sma, sops, nsops, un, current->tgid); if (error <= 0) goto update; @@ -1064,7 +1064,7 @@ retry_undos: queue.sops = sops; queue.nsops = nsops; queue.undo = un; - queue.pid = current->pid; + queue.pid = current->tgid; queue.id = semid; if (alter) append_to_queue(sma ,&queue); @@ -1206,7 +1206,7 @@ found: sem->semval += u->semadj[i]; if (sem->semval < 0) sem->semval = 0; /* shouldn't happen */ - sem->sempid = current->pid; + sem->sempid = current->tgid; } } sma->sem_otime = get_seconds(); diff -puN ipc/shm.c~ipc-use-tgid ipc/shm.c --- 25/ipc/shm.c~ipc-use-tgid Thu Aug 28 11:55:27 2003 +++ 25-akpm/ipc/shm.c Thu Aug 28 11:55:27 2003 @@ -89,7 +89,7 @@ static inline void shm_inc (int id) { if(!(shp = shm_lock(id))) BUG(); shp->shm_atim = get_seconds(); - shp->shm_lprid = current->pid; + shp->shm_lprid = current->tgid; shp->shm_nattch++; shm_unlock(shp); } @@ -136,7 +136,7 @@ static void shm_close (struct vm_area_st /* remove from the list of attaches of the shm segment */ if(!(shp = shm_lock(id))) BUG(); - shp->shm_lprid = current->pid; + shp->shm_lprid = current->tgid; shp->shm_dtim = get_seconds(); shp->shm_nattch--; if(shp->shm_nattch == 0 && @@ -209,7 +209,7 @@ static int newseg (key_t key, int shmflg if(id == -1) goto no_id; - shp->shm_cprid = current->pid; + shp->shm_cprid = current->tgid; shp->shm_lprid = 0; shp->shm_atim = shp->shm_dtim = 0; shp->shm_ctim = get_seconds(); _