tprctl: enhance sighandler to explicitly print si_code

The current sighandler only restores the environment saved before, we
can not tell the SIGBUS reason. Therefore, explictly print si_code like
we do in tsimpleinj, 4 for BUS_MCEERR_AR, and 5 for BUS_MCEERR_AO.

Signed-off-by: Shuai Xue <xueshuai@linux.alibaba.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
diff --git a/cases/function/hwpoison/tprctl.c b/cases/function/hwpoison/tprctl.c
index d07e9d2..41a992b 100644
--- a/cases/function/hwpoison/tprctl.c
+++ b/cases/function/hwpoison/tprctl.c
@@ -39,8 +39,10 @@
 sigjmp_buf recover_ctx;
 volatile int seq;
 
-void handler(int sig)
+void sighandler(int sig, siginfo_t *si, void *arg)
 {
+	printf("signal %d code %d addr %p\n", sig, si->si_code, si->si_addr);
+
 	siglongjmp(recover_ctx, 1);
 }
 
@@ -51,7 +53,11 @@
 			 MAP_PRIVATE|MAP_ANONYMOUS|MAP_POPULATE, 0,0);
 	if (ptr == (char *)-1L)
 		err("mmap");
-	signal(SIGBUS, handler);
+	struct sigaction sa = {
+		.sa_sigaction = sighandler,
+		.sa_flags = SA_SIGINFO
+	};
+	sigaction(SIGBUS, &sa, NULL);
 	printf("ptr = %p\n", ptr);
 	if (sigsetjmp(recover_ctx, 1) == 0) { 
 		seq = 0;