comparison toys/other/usleep.c @ 653:2986aa63a021

Move commands into "posix", "lsb", and "other" menus/directories.
author Rob Landley <rob@landley.net>
date Sat, 25 Aug 2012 14:25:22 -0500
parents toys/usleep.c@131571cf708c
children 6df4ccc0acbe
comparison
equal deleted inserted replaced
652:2d7c56913fda 653:2986aa63a021
1 /* vi: set sw=4 ts=4:
2 *
3 * usleep.c - Wait for a number of microseconds.
4 *
5 * Copyright 2012 Elie De Brauwer <eliedebrauwer@gmail.com>
6 *
7 * No standard.
8
9 USE_USLEEP(NEWTOY(usleep, "<1", TOYFLAG_BIN))
10
11 config USLEEP
12 bool "usleep"
13 default y
14 help
15 usage: usleep MICROSECONDS
16
17 Pause for MICROSECONDS microseconds.
18
19 */
20
21 #include "toys.h"
22
23 void usleep_main(void)
24 {
25 struct timespec tv;
26 long delay = atol(*toys.optargs);
27
28 tv.tv_sec = delay/1000000;
29 tv.tv_nsec = (delay%1000000) * 1000;
30 toys.exitval = !!nanosleep(&tv, NULL);
31
32 }