Skip to contentSkip to conversation

Sending siginfo from kernel to user space

DISCUSSION [email protected] 1 participant 1 message Sep 2, 2004

lore
Share & tools
lore
#0 lore raw

I am sending a signal from kernel space to user space with Linux 2.4.20-8.

In user space, I have installed a signal handler:

    saio.sa_handler = signal_handler_IO;

    sigemptyset(&saio.sa_mask);

    saio.sa_flags = SA_SIGINFO;

    saio.sa_restorer = NULL;

    sigaction(SA_SIGINFO, &saio, NULL);

In kernel space:

    info.si_errno = 1212;

    info.si_code  = SI_KERNEL;

    send_sig_info(SA_SIGINFO, &info, find_task_by_pid(pid));

This results in the signal handler,

void signal_handler_IO (int status, struct siginfo *info, void *p)

being called in user space, which gives the following values in info:

    info->si_signo = 4  /* corresponds to SA_SIGINFO */

    info->si_errno = 0  /* expect 1212               */

    info->si_code  = 0  /* expect SI_KERNEL (128)    */ 

Note that the values I put in si_errno and si_code do not get passed to the user. si_signo has the correct value, but the user can know this from the original sigaction call.

If instead, I call send_sig_info(SA_SIGINFO, (struct siginfo*)0, find_task_by_pid(pid)), as expected I get:

    info->si_signo = 4  

    info->si_errno = 0

    info->si_code  = 0  /* corresponds to SI_USER, as expected */

If I call send_sig_info(SA_SIGINFO, (struct siginfo*)1, find_task_by_pid(pid)), as expected I get:

    info->si_signo = 4  

    info->si_errno = 0

    info->si_code  = 128    /* corresponds to SI_KERNEL, as expected */

Apparently, there is a problem copying the info structure. I need to pass info to the kernel. Any ideas?

Thank you.