From owner-freebsd-hackers@FreeBSD.ORG Thu Mar 17 19:55:13 2005 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 2BDA516A567 for ; Thu, 17 Mar 2005 19:55:13 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.198]) by mx1.FreeBSD.org (Postfix) with ESMTP id 99D1E43D2D for ; Thu, 17 Mar 2005 19:55:12 +0000 (GMT) (envelope-from opensource.enthousiat@gmail.com) Received: by wproxy.gmail.com with SMTP id 69so275604wri for ; Thu, 17 Mar 2005 11:55:12 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=ijG2KJY4oqVyZNSs5ih2jpIS+RfUZRmkeAobnYbWV+02Czdak38uLuvK08ZmpB4WQqTRreDgt7vwvGxmFFV5j0biAdGxB3Nd1V8Y7GAolkFaIje8ccvy7eBQwsV5LNc1R1L5ygSgMHJJ/yzS43v6aEhOqXTruUcUNa9vIczCWcU= Received: by 10.54.57.25 with SMTP id f25mr2004807wra; Thu, 17 Mar 2005 11:55:11 -0800 (PST) Received: by 10.54.49.28 with HTTP; Thu, 17 Mar 2005 11:55:11 -0800 (PST) Message-ID: <37e1316605031711555c47c8ca@mail.gmail.com> Date: Thu, 17 Mar 2005 14:55:11 -0500 From: Aziz KEZZOU To: John-Mark Gurney , Aziz KEZZOU , freebsd-hackers@freebsd.org In-Reply-To: <20050317181200.GK89312@funkthat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit References: <37e13166050317093477de8f7a@mail.gmail.com> <20050317181200.GK89312@funkthat.com> Subject: Re: How to send a signal from inside the kernel? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Aziz KEZZOU List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Mar 2005 19:55:13 -0000 > Aziz KEZZOU wrote this message on Thu, Mar 17, 2005 at 12:34 -0500: > > Hi all, > > I would like to send a signal (e.g SIGUSR1) to a user process from > > inside the kernel (kld module). > > Can any one tell me how to do it ? > > I tried the following code inspired from sys/kern/kern_sig.c : > > ============================================================== > > #include > > #include > > > > int process_pid; > > struct kill_args { > > int pid; > > int signum; > > }; > > > > void send_SIGUSR1() { > > struct kill_args uap; > > uap.pid = process_pid; > > uap.signum = SIGUSR1; > > kill((struct thread *)0, &uap); > > } > > =============================================================== > > > > 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... > > 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... It works, thanks a lot !! Here are the headers needed in case someone reads this thread: #include /*needed only for NULL, can be removed*/ #include #include #include #include #include Have fun, Aziz