regarding signals...

Don Lewis truckman at FreeBSD.org
Tue Jun 22 20:23:47 PDT 2004


On 22 Jun, pradeep reddy punnam wrote:
> Hi,
>  
> i am modifing my ../netinet/ip_input.c code so that kernel can inform a 
> user process about the arrival of a packet, i want to use signaling 
> mechanism for this , i know the pid of the process to which the signal 
> should be send, i am looking for exact function that can help me in 
> sending SIGIO to procss...
> i tryed to use the kill and psignal functions but the system going  
> panic when the packet arrives...may be my use of the fuctions is wrong...
> can i call a system call from the kernel....
> somebody tell me what functions are suitable to call for such a 
> situation....
> thanking you...

Take a look at how the various FIOSETOWN ioctl() handlers are written.
The pid or process group id is passed to ioctl(), and the kernel passes
this to fsetown(), which does a lookup on the pid (or pgrp id) and
stores a pointer to the process or process group in a struct sigio, and
a pointer to this structures is stored in the location specified as the
second argument to fsetown(). When the file descriptor that was passed
to ioctl() is closed, funsetown() gets called.

When an event that should trigger the SIGIO is detected, pgsigio()
should be called with a pointer to a pointer to the appropriate struct
sigio.

One of the things that gets handled automagically is that when the
process or process group that is supposed to receive the SIGIO exits,
the SIGIO handling is disabled so that some other process that inherits
the same pid at a later time doesn't start receiving unexpected signals.

Instead of writing some custom kernel code for this, why don't you just
use bpf, which already implements the FIOSETOWN ioctl() call?





More information about the freebsd-hackers mailing list