Date: Sun, 27 Oct 2002 00:07:54 +0800 From: Leslie Jackson <int@softhome.net> To: freebsd-hackers@freebsd.org Subject: [About SA_SIGINFO] Getting signal sender's PID and RUID Message-ID: <20021027000754.064fbe11.int@softhome.net>
next in thread | raw e-mail | index | archive | help
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 majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021027000754.064fbe11.int>
