From owner-freebsd-hackers@FreeBSD.ORG Wed Jun 23 03:23:46 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E808016A4CE for ; Wed, 23 Jun 2004 03:23:46 +0000 (GMT) Received: from gw.catspoiler.org (217-ip-163.nccn.net [209.79.217.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id AB73543D49 for ; Wed, 23 Jun 2004 03:23:46 +0000 (GMT) (envelope-from truckman@FreeBSD.org) Received: from FreeBSD.org (mousie.catspoiler.org [192.168.101.2]) by gw.catspoiler.org (8.12.11/8.12.11) with ESMTP id i5N3N5Bh053115; Tue, 22 Jun 2004 20:23:09 -0700 (PDT) (envelope-from truckman@FreeBSD.org) Message-Id: <200406230323.i5N3N5Bh053115@gw.catspoiler.org> Date: Tue, 22 Jun 2004 20:23:05 -0700 (PDT) From: Don Lewis To: prady_p@yahoo.com In-Reply-To: <20040623024623.31040.qmail@web53406.mail.yahoo.com> MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii cc: freebsd-hackers@FreeBSD.org Subject: Re: regarding signals... X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jun 2004 03:23:47 -0000 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?