linux 暂停的进程,如何暂停/重启C(linux)中的进程

嗨我必须为系统调用编写2个函数来管理操作系统中任务的执行。我无法找到暂停/重新启动进程的方法。我已经找到了信号的名单,我知道杀功能,这里是我的代码:如何暂停/重启C(linux)中的进程

#include

#include

typedef struct File

{

int pid;

struct File *pids;

} *file;

file file1 = NULL;

//this fonction is to suspend a process using its pid number

int V(int pid_num)

{

//does the kill fonction just kill the process or will it take into account the signal argument?

kill(pid_num, SIGSTOP);

file1 = ajouter(file1, pid_num);

return 0;

}

//this is to restart the process

int C()

{

if (file1 != NULL)

{

//I know the kill fonction is not the right one but I just don't know any other to take as argument the pid of a process to restart it

kill(file1->pid, SIGCONT);

}

return 0;

}

//this fontion adds pid number to our structure

file ajouter(file file_n, int pid)

{

file nouveau = malloc(sizeof(file));

nouveau->pid = pid;

nouveau->pids = file_n;

return nouveau;

}

备注:此代码是不应该真正发挥作用,它只是一点点模拟 感谢很多提前

2012-02-15

vallllll

+1

为什么你使用全局'file1'并将它作为'ajouter'的参数?这是无用的,全球选择或不选择,但不混合。 此外,更喜欢'next'而不是'pids',因为这是一个链式列表 –

2012-02-15 16:25:26

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值