Mercurial > hg > toybox
changeset 118:93da7cc220e6
Add sleep.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 17 May 2007 02:38:27 -0400 |
parents | 07d8795fc19c |
children | 8b5ae5f607af |
files | toys.h toys/Config.in toys/sleep.c toys/toylist.h |
diffstat | 4 files changed, 25 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/toys.h Thu May 17 02:38:17 2007 -0400 +++ b/toys.h Thu May 17 02:38:27 2007 -0400 @@ -50,7 +50,7 @@ extern struct toy_context { struct toy_list *which; // Which entry in toy_list is this one? int exitval; // Value error_exit feeds to exit() - char **argv; // Command line arguments + char **argv; // Original command line arguments unsigned optflags; // Command line option flags from get_optflags() char **optargs; // Arguments left over from get_optflags() } toys;
--- a/toys/Config.in Thu May 17 02:38:17 2007 -0400 +++ b/toys/Config.in Thu May 17 02:38:27 2007 -0400 @@ -217,6 +217,14 @@ -f Show final location, including normal files and multiple symlinks. +config SLEEP + bool "sleep" + default n + help + usage: sleep SECONDS + + Wait a decimal integer number of seconds. + config SYNC bool "sync" default n
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toys/sleep.c Thu May 17 02:38:27 2007 -0400 @@ -0,0 +1,11 @@ +/* vi: set sw=4 ts=4: */ +/* + * sleep.c - Wait for a number of seconds. + */ + +#include "toys.h" + +int sleep_main(void) +{ + return sleep(atol(*toys.optargs)); +}
--- a/toys/toylist.h Thu May 17 02:38:17 2007 -0400 +++ b/toys/toylist.h Thu May 17 02:38:27 2007 -0400 @@ -45,6 +45,10 @@ struct ext2_superblock sb; }; +struct sleep_data { + long seconds; +}; + struct touch_data { char *ref_file; char *time; @@ -97,6 +101,7 @@ USE_PWD(NEWTOY(pwd, NULL, TOYFLAG_BIN)) USE_READLINK(NEWTOY(readlink, "<1f", TOYFLAG_BIN)) USE_TOYSH(OLDTOY(sh, toysh, "c:i", TOYFLAG_BIN)) +USE_SLEEP(NEWTOY(sleep, "<1", TOYFLAG_BIN)) USE_SYNC(NEWTOY(sync, NULL, TOYFLAG_BIN)) USE_TOUCH(NEWTOY(touch, "l#t:r:mca", TOYFLAG_BIN)) USE_TOYSH(NEWTOY(toysh, "c:i", TOYFLAG_BIN))