mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-22 10:30:13 +00:00
Defensive programming: make sure that a process is actually running before we try to kill it.
This commit is contained in:
parent
37a4200f40
commit
06123fefe2
@ -28,7 +28,7 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* @(#)$Id: process.c,v 1.11 2010/09/14 18:55:04 dak664 Exp $
|
* @(#)$Id: process.c,v 1.12 2010/10/20 22:24:46 adamdunkels Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,6 +129,13 @@ exit_process(struct process *p, struct process *fromprocess)
|
|||||||
|
|
||||||
PRINTF("process: exit_process '%s'\n", PROCESS_NAME_STRING(p));
|
PRINTF("process: exit_process '%s'\n", PROCESS_NAME_STRING(p));
|
||||||
|
|
||||||
|
/* Make sure the process is in the process list before we try to
|
||||||
|
exit it. */
|
||||||
|
for(q = process_list; q != p && q != NULL; q = q->next);
|
||||||
|
if(q == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(process_is_running(p)) {
|
if(process_is_running(p)) {
|
||||||
/* Process was running */
|
/* Process was running */
|
||||||
p->state = PROCESS_STATE_NONE;
|
p->state = PROCESS_STATE_NONE;
|
||||||
@ -150,7 +157,7 @@ exit_process(struct process *p, struct process *fromprocess)
|
|||||||
p->thread(&p->pt, PROCESS_EVENT_EXIT, NULL);
|
p->thread(&p->pt, PROCESS_EVENT_EXIT, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p == process_list) {
|
if(p == process_list) {
|
||||||
process_list = process_list->next;
|
process_list = process_list->next;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user