Re: Problem of sigaction

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

 



Hi!

On 09:48 Tue 09 Sep     , Wang Yu wrote:
> I have the following questions:
> 1. In line 58 when I call sigaction to associate a action
> handler(act.sa_handler or act.sa_sigaction)
>     with a signal SIGUSR1, how can I pass a parameter(for
> example:pthread_id1) to the handler?

I do not think this is possible. Why do you want to do this? You can store
whatever you want to pass as a global variable.

> 2. In thread1 when it receives a signal SIGUSR1, it will call the handler
> reintegration. From the running
>    result we can find that the thread id of thread1 is 1082132832 (from line
> 77) and the thread id of
>    reintegration is 1082132832l (from line 80). Is there some relation
> between these two thread id ?

No, it is completly random and even if you find out this is not the case it
might be random in a future kernel version. See "man 2 clone" (thi syscall
behind pthread_create):

       CLONE_THREAD (since Linux 2.4.0-test8)

...

              Each  thread  has its own signal mask, as set by sigprocmask(2),
              but signals can be pending either: for the whole process  (i.e.,
              deliverable  to  any member of the thread group), when sent with
              kill(2); or for an individual thread, when sent with  tgkill(2).
              A  call  to sigpending(2) returns a signal set that is the union
              of the signals pending for the whole  process  and  the  signals
              that are pending for the calling thread.

              If  kill(2)  is used to send a signal to a thread group, and the
              thread group has installed a handler for the  signal,  then  the
              handler  will  be  invoked  in exactly one, arbitrarily selected
              member of the thread group that has not blocked the signal.   If
              multiple  threads in a group are waiting to accept the same sig-
              nal using sigwaitinfo(2), the kernel will arbitrarily select one
              of these threads to receive a signal sent using kill(2).


Be *very* careful not to create any race conditions!
	-Michi
-- 
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux