I have written a kernel module that supplies some information about a hardware interrupt to user-space. Currently, the user-space application uses IOCTL to send its PID x
to the kernel module. The kernel module then uses this PID to find the task and send the signal:
#define CUSTOM_SIGNAL 44
struct siginfo info;
memset(&info, 0, sizeof(struct siginfo));
info.si_signo = CUSTOM_SIGNAL;
info.si_code = SI_QUEUE;
info.si_int = 0;
struct task_struct *t = pid_task(find_pid_ns(x, &init_pid_ns), PIDTYPE_PID);
send_sig_info(CUSTOM_SIGNAL, &info, t);
This works really well. However, I find it rather tricky to maintain a dynamic list of PID receivers for a single signal. For this reason I would like to broadcast the signal be default to all running processes (so they need not register to be notified -- it just happens).
One example I can think of that mimics this behaviour is the system shutdown signal. Is it possible to simply broadcast my CUSTOM_SIGNAL, or do I need to iterate over all PIDs, sending one-by-one as above. Or is there a special task representing broadcast?