From: Jakub Jelinek <jakub@redhat.com>
To: linux-kernel@vger.rutgers.edu
Subject: siginfo testing program
Date: Wed, 19 Jan 2000 14:29:54 +0100 [thread overview]
Message-ID: <20000119142954.E2708@mff.cuni.cz> (raw)
[-- Attachment #1: Type: text/plain, Size: 461 bytes --]
Hi!
Attached is a patch to test some of the common fault types and whether
proper siginfo is filled out (I forgot to send it with my last patch).
Compile with -D_GNU_SOURCE -lm.
Cheers,
Jakub
___________________________________________________________________
Jakub Jelinek | jakub@redhat.com | http://sunsite.mff.cuni.cz/~jj
Linux version 2.3.40 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________
[-- Attachment #2: siginfotest.c --]
[-- Type: text/plain, Size: 2438 bytes --]
#include <stdio.h>
#include <signal.h>
#include <setjmp.h>
#include <fenv.h>
#include <unistd.h>
#include <sys/mman.h>
jmp_buf j;
int handler(int signum, siginfo_t *info)
{
printf("sig %d\n", signum);
printf("si_signo %d si_errno %d si_code %d\n", info->si_signo, info->si_errno, info->si_code);
switch (signum) {
case SIGFPE:
case SIGBUS:
case SIGILL:
case SIGSEGV:
printf("si_addr %08x", info->si_addr);
#ifdef __sparc__
printf(" si_trapno %08x", *(int *)((&info->si_addr)+1));
#endif
printf("\n");
break;
case SIGCHLD:
printf("si_pid %d si_uid %d si_status %d\n", info->si_pid, info->si_uid, info->si_status);
printf("si_utime %ld si_stime %ld", info->si_utime, info->si_stime);
#ifdef __i386__
printf(" si_uid32 %d", ((unsigned int *)&info->si_stime)[1]);
#endif
printf("\n");
}
siglongjmp(j, 1);
}
static int zero = 0;
double zerod = 0.0;
double small = 1e-30;
double big = 1e+100;
double a, b, c;
unsigned long d;
int main(void)
{
struct sigaction sa;
static int aa[10];
int status;
char *map;
map = mmap(NULL, 8192, PROT_READ, MAP_PRIVATE|MAP_ANON, -1, 0);
if (map == MAP_FAILED)
perror("mmap");
sa.sa_handler = (void *)handler;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO;
if (sigaction(SIGSEGV, &sa, NULL) < 0)
perror("sigaction");
if (sigaction(SIGBUS, &sa, NULL) < 0)
perror("sigaction");
if (sigaction(SIGFPE, &sa, NULL) < 0)
perror("sigaction");
if (sigaction(SIGILL, &sa, NULL) < 0)
perror("sigaction");
if (sigaction(SIGCHLD, &sa, NULL) < 0)
perror("sigaction");
if (!sigsetjmp(j, 1)) {
*(volatile int *)0x4000 = 0;
}
if (!sigsetjmp(j, 1)) {
map[56] = 0;
}
if (!sigsetjmp(j, 1)) {
unsigned long a = (long)&aa[5];
a += 5;
*(volatile int *)(a) = 0;
}
if (!sigsetjmp(j, 1)) {
fesetenv(FE_NOMASK_ENV);
d = 26 / zero;
}
if (!sigsetjmp(j, 1)) {
fesetenv(FE_NOMASK_ENV);
a = 26.0 / zerod;
}
if (!sigsetjmp(j, 1)) {
fesetenv(FE_NOMASK_ENV);
b = zerod / zerod;
}
if (!sigsetjmp(j, 1)) {
fesetenv(FE_NOMASK_ENV);
c = small + big;
}
if (!sigsetjmp(j, 1)) {
int pid = fork();
if (pid < 0) perror("fork");
if (!pid) {
sleep(2);
exit(4);
}
sleep(5);
}
wait(&status);
printf("status %08x\n", status);
if (!sigsetjmp(j, 1)) {
int pid = fork();
if (pid < 0) perror("fork");
if (!pid) {
kill(getpid(), SIGUSR1);
exit(4);
}
sleep(5);
}
wait(&status);
printf("status %08x\n", status);
return 0;
}
reply other threads:[~2000-01-19 13:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20000119142954.E2708@mff.cuni.cz \
--to=jakub@redhat.com \
--cc=linux-kernel@vger.rutgers.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®