Emaborsa
19-01-2011, 16:42
Sto facendo un progettino per l'università, in pratica l'ho finito. Una mini shell.
Ho implementato un comando KILL che va a terminare un processo usando il pid_number. Il problema che riscontro, è quando scrivo kill <pidNumber> la shell mi da "segmentation error" e torna alla bash di sistema. Il codice per eseguire questo comando mi sembra semplice:
void killJob(int jobId)
{
t_job *job = getJob(jobId, BY_JOB_ID); // get the job from the list
kill(job->pid, SIGKILL); // send the job a SIGKILL signal
}
...
...
...
if (strcmp("kill", commandArgv[0]) == 0) {
if (commandArgv[1] == NULL)
return 0;
killJob(atoi(commandArgv[1]));
return 1;
}
Eppure non va.....qualche suggerimento?
EDIT:
Ho fatto qualche prova e ho constatato che il problema sta nel
kill(job->pid, SIGKILL);
Ho implementato un comando KILL che va a terminare un processo usando il pid_number. Il problema che riscontro, è quando scrivo kill <pidNumber> la shell mi da "segmentation error" e torna alla bash di sistema. Il codice per eseguire questo comando mi sembra semplice:
void killJob(int jobId)
{
t_job *job = getJob(jobId, BY_JOB_ID); // get the job from the list
kill(job->pid, SIGKILL); // send the job a SIGKILL signal
}
...
...
...
if (strcmp("kill", commandArgv[0]) == 0) {
if (commandArgv[1] == NULL)
return 0;
killJob(atoi(commandArgv[1]));
return 1;
}
Eppure non va.....qualche suggerimento?
EDIT:
Ho fatto qualche prova e ho constatato che il problema sta nel
kill(job->pid, SIGKILL);