こんにちは私は、オペレーティングシステムのタスクの実行を管理するシステムコールの2つの機能を記述する必要があります。プロセスを中断/再開する方法が見つかりませんでした。シグナルのリストを私が発見したと私はキル機能を知っているし、ここに私のコードです:C(linux)でプロセスを中断/再開する方法
#include <stdlib.h>
#include <signal.h>
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;
}
発言:このコードは実際に動作するようになっていないことが多く、事前に おかげ
グローバルな 'file1'を' ajouter'のパラメータとして使うのはなぜですか?これは役に立たず、グローバルかどうかを選択しますが、ミックスしないでください。 また、 'pids'の代わりに' next'を使います。これは連鎖リストなので – Eregrith