diff options
Diffstat (limited to 'src/bltin/times.c')
-rw-r--r-- | src/bltin/times.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/bltin/times.c b/src/bltin/times.c new file mode 100644 index 0000000..d8a35dc --- /dev/null +++ b/src/bltin/times.c @@ -0,0 +1,32 @@ +/* + * Copyright (c) 1999 Herbert Xu <herbert@debian.org> + * This file contains code for the times builtin. + * $Id$ + */ + +#include <sys/times.h> +#include <unistd.h> +#ifdef USE_GLIBC_STDIO +#include <stdio.h> +#else +#include "bltin.h" +#endif + +#define main timescmd + +int main() { + struct tms buf; + long int clk_tck = sysconf(_SC_CLK_TCK); + + times(&buf); + printf("%dm%fs %dm%fs\n%dm%fs %dm%fs\n", + (int) (buf.tms_utime / clk_tck / 60), + ((double) buf.tms_utime) / clk_tck, + (int) (buf.tms_stime / clk_tck / 60), + ((double) buf.tms_stime) / clk_tck, + (int) (buf.tms_cutime / clk_tck / 60), + ((double) buf.tms_cutime) / clk_tck, + (int) (buf.tms_cstime / clk_tck / 60), + ((double) buf.tms_cstime) / clk_tck); + return 0; +} |