From owner-freebsd-hackers Sat Oct 26 9: 8:29 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8036337B401 for ; Sat, 26 Oct 2002 09:08:27 -0700 (PDT) Received: from jive.SoftHome.net (jive.SoftHome.net [66.54.152.27]) by mx1.FreeBSD.org (Postfix) with SMTP id E9E5943E75 for ; Sat, 26 Oct 2002 09:08:26 -0700 (PDT) (envelope-from int@softhome.net) Received: (qmail 23116 invoked by uid 417); 26 Oct 2002 16:08:16 -0000 Received: from shunt-smtp-out-0 (HELO softhome.net) (172.16.3.12) by shunt-smtp-out-0 with SMTP; 26 Oct 2002 16:08:16 -0000 Received: from int.homeunix.org ([218.58.241.112]) (AUTH: LOGIN int@softhome.net) by softhome.net with esmtp; Sat, 26 Oct 2002 10:08:12 -0600 Date: Sun, 27 Oct 2002 00:07:54 +0800 From: Leslie Jackson To: freebsd-hackers@freebsd.org Subject: [About SA_SIGINFO] Getting signal sender's PID and RUID Message-Id: <20021027000754.064fbe11.int@softhome.net> X-Mailer: Sylpheed version 0.7.6 (GTK+ 1.2.10; i386-portbld-freebsd4.6) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 #include #include #include #include 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