How to send a signal from inside the kernel?

Robert Watson rwatson at FreeBSD.org
Fri Mar 18 06:25:16 PST 2005


On Thu, 17 Mar 2005, John-Mark Gurney wrote:

> > but that causes a page fault in kernel mode (ie. Kernel panic :-)
> > 
> > Any help is appreciated, thanks.
> 
> Take a look at psignal(9)...  You'll need to look up the struct proc for
> psignal with pfind(9)...  and then PROC_UNLOCK the struct proc after
> you've used psignal... 

Depending on the circumstances, it may also be appropriate to add an
access control check in the form: 

    error = p_cansignal(td, p);
    if (error) {
        PROC_UNLOCK(p);
        return (error);
    }

Where 'td' is the requesting thread, and 'p' is the target process.

Robert N M Watson


> 
> so:
> struct proc *p;
> 
> p = pfind(pid);
> if (p != NULL) {
> 	psignal(p, SIGUSR1);
> 	PROC_UNLOCK(p);
> }
> 
> I haven't tried the code above, but that should do what you want...
> 
> -- 
>   John-Mark Gurney				Voice: +1 415 225 5579
> 
>      "All that I will do, has been done, All that I have, has not."
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
> 



More information about the freebsd-hackers mailing list