POSIX-timers: is this a bug?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I`m not on list, so please CC me.

When setting a new timer with timer_create() one can supply a sigevent_t
structure, within one can supply a thread ID (by setting
->sigev_notify_thread_id and SIGEV_THREAD_ID | SIGEV_SIGNAL). You can
use this to get the thread signalled when the timer expires with the
given signal.

Even though the thread ID is asked for, in reality the PID is required -
as you can see in the code below. Because the associated task is located
by PID, not by PID. This collides with the API description for
timer_create(): 
"timer_create creates an interval timer based on the POSIX 1003.1b
standard using the clock type specified by which_clock. The timer ID is
stored in the timer_t value pointed to by created_timer_id.
The timer is started by timer_settime (3). If timer_event_spec is
non-NULL, it specifies the behavior on timer expiration.  If the
sigev_notify member of timer_event_spec is SIGEV_SIGNAL then the signal
specified by sigev_signo is sent to the process on expiration.
If the value is SIGEV_THREAD_ID then the sigev_notify_thread_id member
of timer_event_spec should contain the pthread_t id of the thread that
is to receive the signal."

As you can see below, the value is used as PID instead of as TID.
Printing out PID and TID of my thread has shown that both values clearly
differ.

Is this a bug?

With kind regards,
Oliver Korpilla

kernel/posix-timers.c (2.6.13.4):

static inline struct task_struct * good_sigevent(sigevent_t * event)
{
	struct task_struct *rtn = current->group_leader;

	if ((event->sigev_notify & SIGEV_THREAD_ID ) &&
	(!(rtn = find_task_by_pid(event->sigev_notify_thread_id)) ||
	rtn->tgid != current->tgid ||
	 (event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_SIGNAL))
		return NULL;

	if (((event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE) &&
	    ((event->sigev_signo <= 0) || 
		(event->sigev_signo > SIGRTMAX)))
		return NULL;

	return rtn;
}


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux