7年嵌入式内核驱动工作,把这些年读过还不错的书籍推荐给大家

我自己写了一个内核模块中有一个部分是要实现结束指定pid的进程的功能。实现此功能的函数如下:
代码:
static int thread_kill(void)
{
   p = &init_task;
   for_each_process(p)
      {
      int tmp = p->tgid;
      if(tmp == thread)
         {
          kthread_stop(p)
         return 0;
         }
      }
   printk(KERN_ERR "this thread doesn't exist!\n");
   return -1;
}


其中,p和thread是全局变量。其中thread作为参数传入。具体定义如下:
代码:
struct task_struct *p = &init_task;
static int thread = 0;   
module_param(thread, int, S_IRUGO);


现在问题是, kthread_stop(p)这条语句无法结束外部进程。比如一个pid为1825的firefox。
经过我测试,确认程序是有执行这条语句的,而且kthread_stop(p)返回值为0.
但firefox依然在运行。。。。
求各位高手帮帮忙。。。
另外。。有其他能结束进程的api也请大家指教下。不胜感激。

作者: hycsos   发布时间: 2011-05-14