* Re: [Fwd: sigcontext on Linux-ppc in user space]
@ 2001-01-25 15:09 jekacur
2001-01-25 18:11 ` Dan Malek
0 siblings, 1 reply; 5+ messages in thread
From: jekacur @ 2001-01-25 15:09 UTC (permalink / raw)
To: linux-kernel, linuxppc-dev
John Kacur/Toronto/IBM@IBMCA
jekacur@ca.ibm.com
(416) 448-2584 (phone)
778-2584 (tie line)
---------------------- Forwarded by John Kacur/Toronto/IBM on 01/25/2001
10:06 AM ---------------------------
John Kacur
01/24/2001 04:47 PM
To: aj@suse.de
cc: aj@arthur.inka.de
From: John Kacur/Toronto/IBM@IBMCA
Subject: Re: [Fwd: sigcontext on Linux-ppc in user space] (Document link:
John Kacur)
Thanks for your reply. Yes, you are right I shouldn't include kernel files
in user space programs, and signal.h will contain what I need anyway. But I
still can't get at the sigcontext.c on Linux Powerpc. For example, this
simple program gives me a segmentation fault. (Linux ppc, suse 6.4, kernel
2.2.14
#include <stdio.h>
#include <signal.h>
/* Function Prototypes */
void install_sigusr1_handler(void);
void sigusr_handler(int , siginfo_t *, struct sigcontext * scp);
int main(void)
{
install_sigusr1_handler();
printf("SIGUSR1 = %d\n", SIGUSR1);
raise(SIGUSR1);
exit(0);
}
void install_sigusr1_handler(void)
{
struct sigaction newAct;
if (sigemptyset(&newAct.sa_mask) != 0) {
fprintf(stderr, "Warning, sigemptyset failed.\n");
}
newAct.sa_flags = 0;
newAct.sa_flags |= SA_SIGINFO | SA_RESTART;
newAct.sa_sigaction = (void
(*)(int,siginfo_t*,void*))sigusr_handler;
if (sigaction(SIGUSR1, &newAct, NULL) != 0) {
fprintf(stderr, "Couldn't install SIGUSR1 handler.\n");
fprintf(stderr, "Exiting.\n");
exit(1);
}
}
void sigusr_handler(int signo, siginfo_t *siginfp, struct sigcontext * scp)
{
printf("scp = %08x\n", scp);
printf("scp->signal = %d\n", scp->signal);
}
Ultimately, I want to get at the regs, ie scp->pt_regs->nip for example.
Any ideas?
Thanks.
John Kacur/Toronto/IBM@IBMCA
jekacur@ca.ibm.com
(416) 448-2584 (phone)
778-2584 (tie line)
John Kacur <jkacur@home.com>@e1.ny.us.ibm.com on 01/24/2001 10:26:30 AM
Please respond to John Kacur <jkacur@home.com>
Sent by: jkacur@e1.ny.us.ibm.com
To: John Kacur/Toronto/IBM@IBMCA
cc:
Subject: [Fwd: sigcontext on Linux-ppc in user space]
----- Message from on -----
John Kacur <jkacur@home.com> writes:
> Does anyone know how to get at the struct sigcontext in a signal handler
> on Linux for powerpc? sigaction of course lets you create a signal
> handler as a function with the prototype void(*)(int, siginfo_t *, void
> *)
> where the last argument, a pointer to void, is the sigcontext. I believe
> that the last argument is NOT defined by POSIX and so is implementation
> dependent.
>
> On Intel it seems sufficient to use #include <asm/sigcontext.h>
> to get the definition of struct sigcontext, and then get the values
> you'd like out of the signal handler. But on Linux for powerpc, the same
> thing doesn't work. Does anyone know what the trick is here to
> accomplish this?
You should never include kernel headers in user space.
If you have a glibc 2.1 (or newer) based system, just include
<signal.h> which will include <bits/sigcontext.h> with the struct
(this works on all architectures).
Andreas
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Fwd: sigcontext on Linux-ppc in user space]
@ 2001-01-25 18:10 Kevin B. Hendricks
0 siblings, 0 replies; 5+ messages in thread
From: Kevin B. Hendricks @ 2001-01-25 18:10 UTC (permalink / raw)
To: jekacur; +Cc: linux-kernel, linuxppc-dev
Hi,
Here is what I get from running it on my system (ppc linux with 2.2.15 kernel with some mods and glibc-2.1.3).
But no segfault.
Kevin
[kbhend@localhost ~]$ gcc -O2 -ojunk junk.c
[kbhend@localhost ~]$ ./junk
SIGUSR1 = 10
scp = 7fffe9a4
scp->signal = 0
[kbhend@localhost ~]$
On Thursday, January 25, 2001, at 10:09 AM, jekacur@ca.ibm.com wrote:
> #include <stdio.h>
> #include <signal.h>
>
> /* Function Prototypes */
> void install_sigusr1_handler(void);
> void sigusr_handler(int , siginfo_t *, struct sigcontext * scp);
>
> int main(void)
> {
> install_sigusr1_handler();
> printf("SIGUSR1 = %d\n", SIGUSR1);
> raise(SIGUSR1);
> exit(0);
> }
>
> void install_sigusr1_handler(void)
> {
> struct sigaction newAct;
>
> if (sigemptyset(&newAct.sa_mask) != 0) {
> fprintf(stderr, "Warning, sigemptyset failed.\n");
> }
>
> newAct.sa_flags = 0;
> newAct.sa_flags |= SA_SIGINFO | SA_RESTART;
>
> newAct.sa_sigaction = (void
> (*)(int,siginfo_t*,void*))sigusr_handler;
>
> if (sigaction(SIGUSR1, &newAct, NULL) != 0) {
> fprintf(stderr, "Couldn't install SIGUSR1 handler.\n");
> fprintf(stderr, "Exiting.\n");
> exit(1);
> }
> }
>
> void sigusr_handler(int signo, siginfo_t *siginfp, struct sigcontext * scp)
> {
> printf("scp = %08x\n", scp);
> printf("scp->signal = %d\n", scp->signal);
> }
>
>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Fwd: sigcontext on Linux-ppc in user space]
2001-01-25 15:09 [Fwd: sigcontext on Linux-ppc in user space] jekacur
@ 2001-01-25 18:11 ` Dan Malek
0 siblings, 0 replies; 5+ messages in thread
From: Dan Malek @ 2001-01-25 18:11 UTC (permalink / raw)
To: jekacur; +Cc: linux-kernel, linuxppc-dev
jekacur@ca.ibm.com wrote:
> ...... But I
> still can't get at the sigcontext.c on Linux Powerpc. For example, this
> simple program gives me a segmentation fault. (Linux ppc, suse 6.4, kernel
> 2.2.14
You are not the only one. I recently discovered some inconsistent
data structures and function calls (sigaction, old_sigaction, different
context structures, etc.). I spent some time trying to sort it out
but didn't have enough time. I was fortunate and just bailed out using
old signal handler semantics. I was using what I believed were the
latest glibc2.1, and also the latest 2.4 kernels (which is what I
was really developing and testing). I mentioned this to some folks
closer to the glibc action, but haven't followed up. Something is
amiss here with PowerPC.
Sorry I can't provide a solution.
-- Dan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Fwd: sigcontext on Linux-ppc in user space]
@ 2001-01-25 18:44 Kevin B. Hendricks
0 siblings, 0 replies; 5+ messages in thread
From: Kevin B. Hendricks @ 2001-01-25 18:44 UTC (permalink / raw)
To: khendricks; +Cc: jekacur, linux-kernel, linuxppc-dev
[-- Attachment #1: Type: text/plain, Size: 585 bytes --]
Hi,
If it matters I am running some kernel fixes to enable RT signal handling properly.
A version of this patch was supposed to be included into the 2.4 series but I don't work with those kernels so I never checked to see if it was ever included.
I have attached the patch which should apply cleanly over stable 2.2 kernels just in case it helps.
By the way, this was not my patch it was contributed awhile ago by someone else.
The 2.3.XX version is out there someplace, perhaps someone remembers where. I backported it to my stable kernel.
Hope this helps,
Kevin
[-- Attachment #2: posix_stable.patch --]
[-- Type: application/octet-stream, Size: 10817 bytes --]
--- arch/ppc/kernel/head.S.prev Wed Apr 26 10:38:24 2000
+++ arch/ppc/kernel/head.S Wed Apr 26 11:02:18 2000
@@ -23,6 +23,10 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
+ *
+ * 2000-04-10.
+ * Add sys_rt_sigreturn in DoSyscall Handler.
+ * Giovanna Ambrosini (ambrosini@lightning.ch).
*
*/
@@ -2169,6 +2173,8 @@
#endif /* SHOW_SYSCALLS */
cmpi 0,r0,0x7777 /* Special case for 'sys_sigreturn' */
beq- 10f
+ cmpi 0,r0,0x6666 /* Special case for 'sys_rt_sigreturn' */
+ beq- 16f
lwz r10,TASK_FLAGS(r2)
andi. r10,r10,PF_TRACESYS
bne- 50f
@@ -2215,6 +2221,12 @@
/* sys_sigreturn */
10: addi r3,r1,STACK_FRAME_OVERHEAD
bl sys_sigreturn
+ cmpi 0,r3,0 /* Check for restarted system call */
+ bge int_return
+ b 20b
+/* sys_rt_sigreturn */
+16: addi r3,r1,STACK_FRAME_OVERHEAD
+ bl sys_rt_sigreturn
cmpi 0,r3,0 /* Check for restarted system call */
bge int_return
b 20b
--- arch/ppc/kernel/signal.c.prev Wed Apr 26 10:38:39 2000
+++ arch/ppc/kernel/signal.c Wed Apr 26 10:56:47 2000
@@ -14,6 +14,16 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
+ *
+ *
+ * 2000-04-7.
+ * Define a real-time signal frame with siginfo and ucontext
+ * structures (setup_rt_frame()).
+ * Stuck up a real-time signal frame when setting the signal
+ * frame with SA_SIGINFO flags.
+ * Add sys_rt_sigreturn() to undo the signal stack.
+ *
+ * Giovanna Ambrosini (ambrosini@lightning.ch)
*/
#include <linux/sched.h>
@@ -121,13 +131,6 @@
}
-asmlinkage int sys_rt_sigreturn(unsigned long __unused)
-{
- printk("sys_rt_sigreturn(): %s/%d not yet implemented.\n",
- current->comm,current->pid);
- do_exit(SIGSEGV);
-}
-
asmlinkage int
sys_sigaltstack(const stack_t *uss, stack_t *uoss)
{
@@ -171,13 +174,11 @@
* When we have signals to deliver, we set up on the
* user stack, going down from the original stack pointer:
* a sigregs struct
- * one or more sigcontext structs
+ * one or more sigcontext structs with
* a gap of __SIGNAL_FRAMESIZE bytes
*
* Each of these things must be a multiple of 16 bytes in size.
*
- * XXX ultimately we will have to stack up a siginfo and ucontext
- * for each rt signal.
*/
struct sigregs {
elf_gregset_t gp_regs;
@@ -188,6 +189,15 @@
int abigap[56];
};
+struct rt_sigframe
+{
+ unsigned long _unused[2];
+ struct siginfo *pinfo;
+ void *puc;
+ struct siginfo info;
+ struct ucontext uc;
+};
+
/*
* Do a signal return; undo the signal stack.
*/
@@ -259,6 +269,91 @@
do_exit(SIGSEGV);
}
+
+/*
+ * When we have rt signals to deliver, we set up on the
+ * user stack, going down from the original stack pointer:
+ * a sigregs struct
+ * one rt_sigframe struct (siginfo + ucontext)
+ * a gap of __SIGNAL_FRAMESIZE bytes
+ *
+ * Each of these things must be a multiple of 16 bytes in size.
+ *
+ */
+asmlinkage int sys_rt_sigreturn(struct pt_regs *regs)
+{
+ struct rt_sigframe *rt_sf;
+ struct sigcontext_struct sigctx;
+ struct sigregs *sr;
+ int ret;
+ elf_gregset_t saved_regs; /* an array of ELF_NGREG unsigned longs */
+ sigset_t set;
+ stack_t st;
+ unsigned long prevsp;
+
+ rt_sf = (struct rt_sigframe *)(regs->gpr[1] + __SIGNAL_FRAMESIZE);
+ if (copy_from_user(&sigctx, &rt_sf->uc.uc_mcontext, sizeof(sigctx))
+ || copy_from_user(&set, &rt_sf->uc.uc_sigmask, sizeof(set))
+ || copy_from_user(&st, &rt_sf->uc.uc_stack, sizeof(st)))
+ goto badframe;
+ sigdelsetmask(&set, ~_BLOCKABLE);
+ spin_lock_irq(¤t->sigmask_lock);
+ current->blocked = set;
+ recalc_sigpending(current);
+ spin_unlock_irq(¤t->sigmask_lock);
+
+ rt_sf++; /* Look at next rt_sigframe */
+ if (rt_sf == (struct rt_sigframe *)(sigctx.regs)) {
+ /* Last stacked signal - restore registers -
+ * sigctx is initialized to point to the
+ * preamble frame (where registers are stored)
+ * see handle_signal()
+ */
+ sr = (struct sigregs *) sigctx.regs;
+ if (regs->msr & MSR_FP )
+ giveup_fpu(current);
+ if (copy_from_user(saved_regs, &sr->gp_regs,
+ sizeof(sr->gp_regs)))
+ goto badframe;
+ saved_regs[PT_MSR] = (regs->msr & ~MSR_USERCHANGE)
+ | (saved_regs[PT_MSR] & MSR_USERCHANGE);
+ memcpy(regs, saved_regs, GP_REGS_SIZE);
+ if (copy_from_user(current->tss.fpr, &sr->fp_regs,
+ sizeof(sr->fp_regs)))
+ goto badframe;
+ /* This function sets back the stack flags into
+ the current task structure. */
+ sys_sigaltstack(&st, NULL);
+
+ ret = regs->result;
+ } else {
+ /* More signals to go */
+ /* Set up registers for next signal handler */
+ regs->gpr[1] = (unsigned long)rt_sf - __SIGNAL_FRAMESIZE;
+ if (copy_from_user(&sigctx, &rt_sf->uc.uc_mcontext, sizeof(sigctx)))
+ goto badframe;
+ sr = (struct sigregs *) sigctx.regs;
+ regs->gpr[3] = ret = sigctx.signal;
+ /* Get the siginfo */
+ get_user(regs->gpr[4], (unsigned long *)&rt_sf->pinfo);
+ /* Get the ucontext */
+ get_user(regs->gpr[5], (unsigned long *)&rt_sf->puc);
+ regs->gpr[6] = (unsigned long) rt_sf;
+
+ regs->link = (unsigned long) &sr->tramp;
+ regs->nip = sigctx.handler;
+ if (get_user(prevsp, &sr->gp_regs[PT_R1])
+ || put_user(prevsp, (unsigned long *) regs->gpr[1]))
+ goto badframe;
+ }
+ return ret;
+
+badframe:
+ lock_kernel();
+ do_exit(SIGSEGV);
+}
+
+
/*
* Set up a signal frame.
*/
@@ -305,6 +400,57 @@
do_exit(SIGSEGV);
}
+
+static void
+setup_rt_frame(struct pt_regs *regs, struct sigregs *frame,
+ signed long newsp)
+{
+ struct rt_sigframe *rt_sf = (struct rt_sigframe *) newsp;
+
+ /* Set up preamble frame */
+ if (verify_area(VERIFY_WRITE, frame, sizeof(*frame)))
+ goto badframe;
+ if (regs->msr & MSR_FP)
+ giveup_fpu(current);
+ if (__copy_to_user(&frame->gp_regs, regs, GP_REGS_SIZE)
+ || __copy_to_user(&frame->fp_regs, current->tss.fpr,
+ ELF_NFPREG * sizeof(double))
+ /* Set up to return from user space.
+ It calls the sc exception at offset 0x9999
+ for sys_rt_sigreturn().
+ */
+ || __put_user(0x38006666UL, &frame->tramp[0]) /* li r0,0x6666 */
+ || __put_user(0x44000002UL, &frame->tramp[1])) /* sc */
+ goto badframe;
+ flush_icache_range((unsigned long) &frame->tramp[0],
+ (unsigned long) &frame->tramp[2]);
+
+ /* Retrieve rt_sigframe from stack and
+ set up registers for signal handler
+ */
+ newsp -= __SIGNAL_FRAMESIZE;
+ if (put_user(regs->gpr[1], (unsigned long *)newsp)
+ || get_user(regs->nip, &rt_sf->uc.uc_mcontext.handler)
+ || get_user(regs->gpr[3], &rt_sf->uc.uc_mcontext.signal)
+ || get_user(regs->gpr[4], (unsigned long *)&rt_sf->pinfo)
+ || get_user(regs->gpr[5], (unsigned long *)&rt_sf->puc))
+ goto badframe;
+
+ regs->gpr[1] = newsp;
+ regs->gpr[6] = (unsigned long) rt_sf;
+ regs->link = (unsigned long) frame->tramp;
+
+ return;
+
+badframe:
+#if DEBUG_SIG
+ printk("badframe in setup_rt_frame, regs=%p frame=%p newsp=%lx\n",
+ regs, frame, newsp);
+#endif
+ lock_kernel();
+ do_exit(SIGSEGV);
+}
+
/*
* OK, we're invoking a handler
*/
@@ -314,6 +460,7 @@
unsigned long *newspp, unsigned long frame)
{
struct sigcontext_struct *sc;
+ struct rt_sigframe *rt_sf;
if (regs->trap == 0x0C00 /* System Call! */
&& ((int)regs->result == -ERESTARTNOHAND ||
@@ -321,20 +468,47 @@
!(ka->sa.sa_flags & SA_RESTART))))
regs->result = -EINTR;
- /* Put another sigcontext on the stack */
- *newspp -= sizeof(*sc);
- sc = (struct sigcontext_struct *) *newspp;
- if (verify_area(VERIFY_WRITE, sc, sizeof(*sc)))
- goto badframe;
+ /* Set up Signal Frame */
+ if (ka->sa.sa_flags & SA_SIGINFO) {
+ /* Put a Real Time Context onto stack */
+ *newspp -= sizeof(*rt_sf);
+ rt_sf = (struct rt_sigframe *) *newspp;
+ if (verify_area(VERIFY_WRITE, rt_sf, sizeof(*rt_sf)))
+ goto badframe;
+
+ if (__put_user((unsigned long) ka->sa.sa_handler, &rt_sf->uc.uc_mcontext.handler)
+ || __put_user(&rt_sf->info, &rt_sf->pinfo)
+ || __put_user(&rt_sf->uc, &rt_sf->puc)
+ /* Put the siginfo */
+ || __copy_to_user(&rt_sf->info, info, sizeof(*info))
+ /* Create the ucontext */
+ || __put_user(0, &rt_sf->uc.uc_flags)
+ || __put_user(0, &rt_sf->uc.uc_link)
+ || __put_user(current->sas_ss_sp, &rt_sf->uc.uc_stack.ss_sp)
+ || __put_user(sas_ss_flags(regs->gpr[1]),
+ &rt_sf->uc.uc_stack.ss_flags)
+ || __put_user(current->sas_ss_size, &rt_sf->uc.uc_stack.ss_size)
+ || __copy_to_user(&rt_sf->uc.uc_sigmask, oldset, sizeof(*oldset))
+ /* mcontext.regs points to preamble register frame */
+ || __put_user((struct pt_regs *)frame, &rt_sf->uc.uc_mcontext.regs)
+ || __put_user(sig, &rt_sf->uc.uc_mcontext.signal))
+ goto badframe;
+ } else {
+ /* Put another sigcontext on the stack */
+ *newspp -= sizeof(*sc);
+ sc = (struct sigcontext_struct *) *newspp;
+ if (verify_area(VERIFY_WRITE, sc, sizeof(*sc)))
+ goto badframe;
- if (__put_user((unsigned long) ka->sa.sa_handler, &sc->handler)
- || __put_user(oldset->sig[0], &sc->oldmask)
+ if (__put_user((unsigned long) ka->sa.sa_handler, &sc->handler)
+ || __put_user(oldset->sig[0], &sc->oldmask)
#if _NSIG_WORDS > 1
- || __put_user(oldset->sig[1], &sc->_unused[3])
+ || __put_user(oldset->sig[1], &sc->_unused[3])
#endif
- || __put_user((struct pt_regs *)frame, &sc->regs)
- || __put_user(sig, &sc->signal))
- goto badframe;
+ || __put_user((struct pt_regs *)frame, &sc->regs)
+ || __put_user(sig, &sc->signal))
+ goto badframe;
+ }
if (ka->sa.sa_flags & SA_ONESHOT)
ka->sa.sa_handler = SIG_DFL;
@@ -494,7 +668,10 @@
if (newsp == frame)
return 0; /* no signals delivered */
- setup_frame(regs, (struct sigregs *) frame, newsp);
+ if (ka->sa.sa_flags & SA_SIGINFO)
+ setup_rt_frame(regs, (struct sigregs *) frame, newsp);
+ else
+ setup_frame(regs, (struct sigregs *) frame, newsp);
return 1;
}
--- include/asm-ppc/ucontext.h.prev Wed Apr 26 10:39:24 2000
+++ include/asm-ppc/ucontext.h Wed Apr 26 10:39:36 2000
@@ -7,6 +7,7 @@
unsigned long uc_flags;
struct ucontext *uc_link;
stack_t uc_stack;
+ struct sigcontext_struct uc_mcontext;
sigset_t uc_sigmask; /* mask last for extensibility */
};
[-- Attachment #3: Type: text/plain, Size: 1914 bytes --]
On Thursday, January 25, 2001, at 01:10 PM, Kevin B. Hendricks wrote:
>
> Hi,
>
> Here is what I get from running it on my system (ppc linux with 2.2.15 kernel with some mods
> and glibc-2.1.3).
>
> But no segfault.
>
> Kevin
>
>
> [kbhend@localhost ~]$ gcc -O2 -ojunk junk.c
> [kbhend@localhost ~]$ ./junk
> SIGUSR1 = 10
> scp = 7fffe9a4
> scp->signal = 0
> [kbhend@localhost ~]$
>
>
>
>
> On Thursday, January 25, 2001, at 10:09 AM, jekacur@ca.ibm.com wrote:
>
> > #include <stdio.h>
> > #include <signal.h>
> >
> > /* Function Prototypes */
> > void install_sigusr1_handler(void);
> > void sigusr_handler(int , siginfo_t *, struct sigcontext * scp);
> >
> > int main(void)
> > {
> > install_sigusr1_handler();
> > printf("SIGUSR1 = %d\n", SIGUSR1);
> > raise(SIGUSR1);
> > exit(0);
> > }
> >
> > void install_sigusr1_handler(void)
> > {
> > struct sigaction newAct;
> >
> > if (sigemptyset(&newAct.sa_mask) != 0) {
> > fprintf(stderr, "Warning, sigemptyset failed.\n");
> > }
> >
> > newAct.sa_flags = 0;
> > newAct.sa_flags |= SA_SIGINFO | SA_RESTART;
> >
> > newAct.sa_sigaction = (void
> > (*)(int,siginfo_t*,void*))sigusr_handler;
> >
> > if (sigaction(SIGUSR1, &newAct, NULL) != 0) {
> > fprintf(stderr, "Couldn't install SIGUSR1 handler.\n");
> > fprintf(stderr, "Exiting.\n");
> > exit(1);
> > }
> > }
> >
> > void sigusr_handler(int signo, siginfo_t *siginfp, struct sigcontext * scp)
> > {
> > printf("scp = %08x\n", scp);
> > printf("scp->signal = %d\n", scp->signal);
> > }
> >
> >
>
> ** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Fwd: sigcontext on Linux-ppc in user space]
@ 2001-01-25 18:50 jekacur
0 siblings, 0 replies; 5+ messages in thread
From: jekacur @ 2001-01-25 18:50 UTC (permalink / raw)
To: khendricks; +Cc: linux-kernel, linuxppc-dev
Ok, actually the segfault was for a more complicated function, but the
simplified example still gives the wrong answer. i.e scp should point to a
struct sigcontext and scp->signal should be 10 in the sample program.
John Kacur/Toronto/IBM@IBMCA
jekacur@ca.ibm.com
(416) 448-2584 (phone)
778-2584 (tie line)
"Kevin B. Hendricks" <khendricks@ivey.uwo.ca> on 01/25/2001 01:10:40 PM
Please respond to khendricks@ivey.uwo.ca
To: John Kacur/Toronto/IBM@IBMCA
cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.linuxppc.org
Subject: Re: [Fwd: sigcontext on Linux-ppc in user space]
Hi,
Here is what I get from running it on my system (ppc linux with 2.2.15
kernel with some mods and glibc-2.1.3).
But no segfault.
Kevin
[kbhend@localhost ~]$ gcc -O2 -ojunk junk.c
[kbhend@localhost ~]$ ./junk
SIGUSR1 = 10
scp = 7fffe9a4
scp->signal = 0
[kbhend@localhost ~]$
On Thursday, January 25, 2001, at 10:09 AM, jekacur@ca.ibm.com wrote:
> #include <stdio.h>
> #include <signal.h>
>
> /* Function Prototypes */
> void install_sigusr1_handler(void);
> void sigusr_handler(int , siginfo_t *, struct sigcontext * scp);
>
> int main(void)
> {
> install_sigusr1_handler();
> printf("SIGUSR1 = %d\n", SIGUSR1);
> raise(SIGUSR1);
> exit(0);
> }
>
> void install_sigusr1_handler(void)
> {
> struct sigaction newAct;
>
> if (sigemptyset(&newAct.sa_mask) != 0) {
> fprintf(stderr, "Warning, sigemptyset failed.\n");
> }
>
> newAct.sa_flags = 0;
> newAct.sa_flags |= SA_SIGINFO | SA_RESTART;
>
> newAct.sa_sigaction = (void
> (*)(int,siginfo_t*,void*))sigusr_handler;
>
> if (sigaction(SIGUSR1, &newAct, NULL) != 0) {
> fprintf(stderr, "Couldn't install SIGUSR1 handler.\n");
> fprintf(stderr, "Exiting.\n");
> exit(1);
> }
> }
>
> void sigusr_handler(int signo, siginfo_t *siginfp, struct sigcontext *
scp)
> {
> printf("scp = %08x\n", scp);
> printf("scp->signal = %d\n", scp->signal);
> }
>
>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2001-01-25 18:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-01-25 15:09 [Fwd: sigcontext on Linux-ppc in user space] jekacur
2001-01-25 18:11 ` Dan Malek
-- strict thread matches above, loose matches on Subject: below --
2001-01-25 18:10 Kevin B. Hendricks
2001-01-25 18:44 Kevin B. Hendricks
2001-01-25 18:50 jekacur
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox