source: rtems/cpukit/libmisc/shell/main_sleep.c @ 2649eef

4.104.115
Last change on this file since 2649eef was a3ddb08b, checked in by Joel Sherrill <joel.sherrill@…>, on 03/05/08 at 02:49:35

2008-03-04 Joel Sherrill <joel.sherrill@…>

  • 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.
  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 *  Sleep Shell Command Implmentation
3 *
4 *  COPYRIGHT (c) 1989-2008.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#ifdef HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <stdio.h>
19#include <time.h>
20
21#include <rtems.h>
22#include <rtems/shell.h>
23#include "internal.h"
24
25int rtems_shell_main_sleep(
26  int   argc,
27  char *argv[]
28)
29{
30  struct timespec delay;
31
32  if (argc == 2) {
33    delay.tv_sec = rtems_shell_str2int(argv[1]);
34    delay.tv_nsec = 0;
35    nanosleep( &delay, NULL );
36    return 0;
37  }
38 
39  if (argc == 3) {
40    delay.tv_sec = rtems_shell_str2int(argv[1]);
41    delay.tv_nsec = rtems_shell_str2int(argv[2]);
42    nanosleep( &delay, NULL );
43    return 0;
44  }
45 
46  fprintf( stderr, "%s: Usage seconds [nanoseconds]\n", argv[0] );
47  return -1;
48}
49
50rtems_shell_cmd_t rtems_shell_SLEEP_Command = {
51  "sleep",                       /* name */
52  "sleep seconds [nanoseconds]", /* usage */
53  "misc",                        /* topic */
54  rtems_shell_main_sleep,        /* command */
55  NULL,                          /* alias */
56  NULL                           /* next */
57};
Note: See TracBrowser for help on using the repository browser.