>    I know that signal handlers can be recursive (tried it) so not going
>back through the kernel makes sense to me...

Here's some example code for this kind of thing.  If you use it as it stands 
you will only get one signal: since you aren't ever threading back out through 
sys_rt_sigreturn the signal never gets unmasked.  But if you are generating 
signals internally in the kernel you can use force_sig to overcome that, and 
you might then get the desired effect.  I haven't tested it, of course.

This actually seems like quite a groovy idea; I might see if we can fix the 
Arthur emulator to use the same trick.

p.

#include <signal.h>
#include <stdio.h>

#include <asm/sigcontext.h>
#include <asm/ucontext.h>

static void
my_handler(int sig, int _a2, int _a3, int _a4, struct siginfo *info,
           struct ucontext *uc)
{
  struct sigcontext *sc = &uc->uc_mcontext;
  write(0, "B", 1);  /* other stuff to taste */
  my_longjmp(sc);
}

main()
{
  struct sigaction sa, old;
  sa.sa_handler = my_handler;
  sigemptyset(&sa.sa_mask);
  sa.sa_flags = SA_SIGINFO;
  if (sigaction(SIGUSR1, &sa, &old))
    {
      perror("sigaction");
      exit(1);
    }
  for (;;)
    {
      write(0, "A", 1);
      raise(SIGUSR1);
    }
}

--

.type my_longjmp, %function
.global my_longjmp
my_longjmp:
        add r0, r0, #12
        ldr r1, [r0, #16*4]
        msr cpsr, r1
        ldmia r0, {r0-pc}


PGP signature

Reply via email to