From 6479f001faf801ba094e721c8732a94f51c18b1a Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Thu, 28 Feb 2008 23:29:07 +0000 Subject: [PATCH] Added a shell_quit() function that cleanly exits the shell (currently untested though) --- apps/shell/shell.c | 23 +++++++++++++++++++---- apps/shell/shell.h | 5 ++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/apps/shell/shell.c b/apps/shell/shell.c index 570a87b60..2a3713bc5 100644 --- a/apps/shell/shell.c +++ b/apps/shell/shell.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: shell.c,v 1.8 2008/02/24 20:35:03 adamdunkels Exp $ + * $Id: shell.c,v 1.9 2008/02/28 23:29:07 adamdunkels Exp $ */ /** @@ -101,11 +101,10 @@ command_kill(struct shell_command *c) } } /*---------------------------------------------------------------------------*/ -PROCESS_THREAD(shell_killall_process, ev, data) +static void +killall(void) { struct shell_command *c; - PROCESS_BEGIN(); - for(c = list_head(commands); c != NULL; c = c->next) { @@ -113,6 +112,14 @@ PROCESS_THREAD(shell_killall_process, ev, data) command_kill(c); } } +} +/*---------------------------------------------------------------------------*/ +PROCESS_THREAD(shell_killall_process, ev, data) +{ + + PROCESS_BEGIN(); + + killall(); PROCESS_END(); } @@ -519,3 +526,11 @@ shell_start(void) shell_prompt("Contiki> "); } /*---------------------------------------------------------------------------*/ +void +shell_quit(void) +{ + killall(); + process_exit(&shell_process); + process_exit(&shell_server_process); +} +/*---------------------------------------------------------------------------*/ diff --git a/apps/shell/shell.h b/apps/shell/shell.h index 12ce312a1..2a5fb8052 100644 --- a/apps/shell/shell.h +++ b/apps/shell/shell.h @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: shell.h,v 1.5 2008/02/24 20:35:03 adamdunkels Exp $ + * $Id: shell.h,v 1.6 2008/02/28 23:29:07 adamdunkels Exp $ */ /** @@ -78,6 +78,9 @@ unsigned long shell_strtolong(const char *str, const char **retstr); unsigned long shell_time(void); void shell_set_time(unsigned long seconds); +void shell_quit(void); + + #define SHELL_COMMAND(name, command, description, process) \ static struct shell_command name = { NULL, command, \ description, process }