segmentation fault while loading modules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




hai,

  I have  a problem in loading a module ,it is giving segmentation fault,
when I do the /sbin/lsmod
 signal4 944 (initializing)

here signal4 is my module name.I am using 2.4.20-8 kernel.
And I am unable to remove this module also.

following is the code of my module

#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_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 x;
struct task_struct *p;
/* run through the task list of linux until we find our pid */
//for (p = &init_task ; (p = next_task(p)) != &init_task ; ){
for (p = &x ; (p = next_task(p)) != &x ; ){
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(2345,SIGKILL);
return 0;
}

void
cleanup_module(void)
{
printk("out of here\n");
}
-----------------------
my makefile is:

TARGET  := signal4
WARN    := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
INCLUDE := -isystem /lib/modules/2.4.20-8feb9.1/build/include
CFLAGS  := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
CC      := gcc

${TARGET}.o: ${TARGET}.c

.PHONY: clean


Any suggestions are welcome.





Thanks&Regards,
  P.Manohar.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux