7年嵌入式内核驱动工作,把这些年读过还不错的书籍推荐给大家
时间:2011-05-14
来源:互联网
我自己写了一个内核模块中有一个部分是要实现结束指定pid的进程的功能。实现此功能的函数如下:
其中,p和thread是全局变量。其中thread作为参数传入。具体定义如下:
现在问题是, kthread_stop(p)这条语句无法结束外部进程。比如一个pid为1825的firefox。
经过我测试,确认程序是有执行这条语句的,而且kthread_stop(p)返回值为0.
但firefox依然在运行。。。。
求各位高手帮帮忙。。。
另外。。有其他能结束进程的api也请大家指教下。不胜感激。
代码:
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 = &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);
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
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28