diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-03-05 02:49:35 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-03-05 02:49:35 +0000 |
commit | a3ddb08bec11871f6e83bb7aaa53a17a4ea5309c (patch) | |
tree | 7a77642c272052b03260156dc5062d23f16e3a35 /cpukit/libmisc/shell/main_sleep.c | |
parent | New. (diff) | |
download | rtems-a3ddb08bec11871f6e83bb7aaa53a17a4ea5309c.tar.bz2 |
2008-03-04 Joel Sherrill <joel.sherrill@oarcorp.com>
* libmisc/Makefile.am, libmisc/shell/main_cp.c,
libmisc/shell/main_cpuuse.c, libmisc/shell/main_date.c,
libmisc/shell/main_mallocinfo.c, libmisc/shell/main_netstats.c,
libmisc/shell/main_perioduse.c, libmisc/shell/main_stackuse.c,
libmisc/shell/main_wkspaceinfo.c, libmisc/shell/print_heapinfo.c,
libmisc/shell/shell.c, libmisc/shell/shell.h,
libmisc/shell/shell_makeargs.c, libmisc/shell/shellconfig.c,
libmisc/shell/shellconfig.h, libmisc/shell/write_file.c: Add initial
capability to automatically execute a script from the filesystem. Add
echo command from NetBSD and sleep command.
* libmisc/shell/main_echo.c, libmisc/shell/main_sleep.c,
libmisc/shell/shell_script.c: New files.
Diffstat (limited to 'cpukit/libmisc/shell/main_sleep.c')
-rw-r--r-- | cpukit/libmisc/shell/main_sleep.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/cpukit/libmisc/shell/main_sleep.c b/cpukit/libmisc/shell/main_sleep.c new file mode 100644 index 0000000000..6ee4cef614 --- /dev/null +++ b/cpukit/libmisc/shell/main_sleep.c @@ -0,0 +1,57 @@ +/* + * Sleep Shell Command Implmentation + * + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdio.h> +#include <time.h> + +#include <rtems.h> +#include <rtems/shell.h> +#include "internal.h" + +int rtems_shell_main_sleep( + int argc, + char *argv[] +) +{ + struct timespec delay; + + if (argc == 2) { + delay.tv_sec = rtems_shell_str2int(argv[1]); + delay.tv_nsec = 0; + nanosleep( &delay, NULL ); + return 0; + } + + if (argc == 3) { + delay.tv_sec = rtems_shell_str2int(argv[1]); + delay.tv_nsec = rtems_shell_str2int(argv[2]); + nanosleep( &delay, NULL ); + return 0; + } + + fprintf( stderr, "%s: Usage seconds [nanoseconds]\n", argv[0] ); + return -1; +} + +rtems_shell_cmd_t rtems_shell_SLEEP_Command = { + "sleep", /* name */ + "sleep seconds [nanoseconds]", /* usage */ + "misc", /* topic */ + rtems_shell_main_sleep, /* command */ + NULL, /* alias */ + NULL /* next */ +}; |