I tried to use sigaction(with SA_SIGINFO sa_flags sepecified) to obtain the
catched signal's sending process ID and its real user ID. But all that i got
are both zeros.

Flatform: FreeBSD 4.6-Release on x86.

----------------------------------8<------------------------------------------
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

static void sig_usr1(int, siginfo_t *, void *);

int main(void)
{
        struct sigaction        act;

        memset(&act, 0, sizeof(act));
        act.sa_flags = SA_SIGINFO;
        act.sa_sigaction = sig_usr1;

        if (sigaction(SIGUSR1, &act, NULL) < 0) {
                perror("sigaction error");
                exit(1);
        }
        
        sleep(3);
        kill(getpid(), SIGUSR1);

        return 0;
}

static void sig_usr1(int signo, siginfo_t *info, void *ptr)
{
        printf("Got SIGUSR1\n");
        printf("sending process ID: %d\n", info->si_pid);
        printf("sending process real user ID: %d\n", info->si_uid);
}
----------------------------------8<------------------------------------------

Anything i've missed? Are there any alternative ways?

Any insights would be appreciated. TIA. :-)

-- 
Leslie Jackson

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to