This discussion is archived
0 Replies Latest reply: Mar 25, 2012 8:42 PM by 926230 RSS

I got an error in my code just calling kill operation

926230 Newbie
Currently Being Moderated
#include <sys/systm.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/kmem.h>
#include <sys/errno.h>
#include <sys/modctl.h>

extern struct mod_ops mod_miscops;
extern struct sysent sysent[];

int (*oldkill) (pid_t pid, int sig);

int newkill(pid_t pid, int sig)
{
cmn_err(CE_NOTE, "In newkill!!!!!!!!!");
return oldkill(pid, sig);
}

static struct modlmisc modlmisc =
{
&mod_miscops,
"TEST Loadable Kernel Module",
};

static struct modlinkage modlinkage =
{
MODREV_1,
(void *) &modlmisc,
NULL
};

int _init(void)
{
int i;

if ((i = mod_install(&modlinkage)) != 0)
     cmn_err(CE_NOTE, "Could not install module\n");
else
     cmn_err(CE_NOTE, "successfully installed");

oldkill = (void *) sysent[SYS_kill].sy_callc;

sysent[SYS_kill].sy_callc = (void *) newkill;

return i;
}

int _info(struct modinfo *modinfop)
{
cmn_err(CE_NOTE, "In _info!!!!!");
return (mod_info(&modlinkage, modinfop));
}


int _fini(void)
{
int i;

if ((i = mod_remove(&modlinkage)) != 0)
     cmn_err(CE_NOTE, "Could not remove module\n");
else
     cmn_err(CE_NOTE, "successfully removed");

sysent[SYS_kill].sy_callc = (void *) oldkill;

return i;
}

///////////////////////////////////////

My simple code is above.

When i typed a kill operation, it is not working.

Maybe the kill operation is not caught by above code.

What is my mistake?? help me T.T

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points