mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Der Herr Hofrat <der.herr@hofr.at>
To: Ravindra Nadgauda <rnadgauda@velankani.com>
Cc: "'Linux Kernel Mailing List'" <linux-kernel@vger.kernel.org>
Subject: Re: Signals/ Communication from kernel to user!
Date: Mon, 28 Feb 2005 20:13:30 +0100 (CET)	[thread overview]
Message-ID: <200502281913.j1SJDUG23870@hofr.at> (raw)
In-Reply-To: <042701c51dab$561ef650$280e000a@blr.velankani.com> from Ravindra Nadgauda at "Feb 28, 2005 09:06:57 pm"

> 
> 
> Hello,
>    We wanted to establish a communication from kernel module (possibly a
> driver) to a user level process.
> 
>    Wanted to know whether signals can be used for this purpose OR there any
> other (better) methods of communication??
>
a bit brute force but you can simply run through the task list and kick
the pid of your user-space app (example for 2.4 kernel): 

hofrat

---snip---
/*
 * Copywrite 2002 Der Herr Hofrat
 * License GPL V2
 * Author der.herr@hofr.at
 */
/*
 * run through the task list of linux search for the passed pid and send it
 * a SIGKILL . run as  insmod pid=#  to send process with pid # a kill signal
 */ 

#include <bits/signum.h>  /* signal number macros SIGHUP etc. */ 
#include <linux/kernel.h> /* printk level */
#include <linux/module.h> /* kernel version etc. */
#include <linux/sched.h>  /* task_struct */

MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Der Herr Hofrat");
MODULE_DESCRIPTION("Signal to a user-space app from a kernel module");

int pid=0; 
MODULE_PARM(pid,"i");

int 
ksignal(int pid,int signum) 
{
	struct task_struct *p;

	/* run through the task list of linux until we find our pid */
	for_each_task(p){
		if(p->pid == pid){
			printk("sending signal %d for pid %d\n",signum,(int)p->pid);
			/* don't have a sig_info struct to send along - pass 0 */
			return send_sig(signum,p,0);
		}
	}
	/* did not find the requested pid */
	return -1;
}

int
init_module(void)
{
	/* send pid a SIGKILL */
	ksignal(pid,SIGKILL);
	return 0;
}

void 
cleanup_module(void) 
{
	printk("out of here\n");
}

  parent reply	other threads:[~2005-02-28 19:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <fa.hgi75u0.1cnmhaa@ifi.uio.no>
2005-02-28 15:23 ` swapper: page allocation failure. order:1, mode:0x20 Benjamin L. Shi
2005-02-28 15:36   ` Signals/ Communication from kernel to user! Ravindra Nadgauda
2005-02-28 16:48     ` Timothy R. Chavez
2005-02-28 19:13     ` Der Herr Hofrat [this message]
2005-02-28 21:17     ` Lee Revell
2005-02-28 15:38   ` swapper: page allocation failure. order:1, mode:0x20 Bernd Schubert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200502281913.j1SJDUG23870@hofr.at \
    --to=der.herr@hofr.at \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rnadgauda@velankani.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®