1 /* 2 * Copyright (c) 1999 Herbert Xu <herbert@gondor.apana.org.au> 3 * This file contains code for the times builtin. 4 */ 5 6 #include <sys/times.h> 7 #include <unistd.h> 8 #ifdef USE_GLIBC_STDIO 9 #include <stdio.h> 10 #else 11 #include "bltin.h" 12 #endif 13 #include "system.h" 14 timescmd()15int timescmd() { 16 struct tms buf; 17 long int clk_tck = sysconf(_SC_CLK_TCK); 18 19 times(&buf); 20 printf("%dm%fs %dm%fs\n%dm%fs %dm%fs\n", 21 (int) (buf.tms_utime / clk_tck / 60), 22 ((double) buf.tms_utime) / clk_tck, 23 (int) (buf.tms_stime / clk_tck / 60), 24 ((double) buf.tms_stime) / clk_tck, 25 (int) (buf.tms_cutime / clk_tck / 60), 26 ((double) buf.tms_cutime) / clk_tck, 27 (int) (buf.tms_cstime / clk_tck / 60), 28 ((double) buf.tms_cstime) / clk_tck); 29 return 0; 30 } 31