How can we know process id of process which is sending the signal - Unix

This is a discussion on How can we know process id of process which is sending the signal - Unix ; How can we know process id of process which is sending the signal?? Process A sends signal to process B. then how can we know process id of A in B??...

+ Reply to Thread
Results 1 to 2 of 2

Thread: How can we know process id of process which is sending the signal

  1. How can we know process id of process which is sending the signal

    How can we know process id of process which is sending the signal??

    Process A sends signal to process B. then how can we know process id
    of A in B??

  2. Re: How can we know process id of process which is sending the signal

    Sanchit wrote:
    > How can we know process id of process which is sending the signal??


    > Process A sends signal to process B. then how can we know process id
    > of A in B??


    If it's possible depends on your system. If the implementation
    supports the XSI Extension option (this sounds more complicated
    then it is, just read your man page for sigaction(2) and check
    if the following is documented ;-) then you set the SA_SIGINFO
    flag in the 'sa_flags' member of the 'sigaction' structure you
    pass to sigaction() when installing the handler and then the
    signal handler function will be called with three arguments
    instead of just one:

    void func( int signo, siginfo_t * info, void * context )

    Now you can test what the structure of type 'siginfo_t' passed
    to the signal handler this way tells you: if the value of its
    'si_code' member is less than or equal to 0 (or compare it to
    'SI_USER'), then the signal was generated by a process (i.e. by
    kill(2) or raise(2) and is not due to e.g. a segmentation fault
    etc.) and 'si_pid' member tells you the ID of the process that
    send the signal.
    Regards, Jens
    --
    \ Jens Thoms Toerring ___ jt@toerring.de
    \__________________________ http://toerring.de

+ Reply to Thread