Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3240 → Rev 3241

/branches/shell/uspace/app/ash/bltin/times.c
0,0 → 1,30
#ifdef _GNU_SOURCE
/*
* Copyright (c) 1999 Herbert Xu <herbert@debian.org>
* This file contains code for the times builtin.
* $Id: ash-0.4.0-cumulative_fixes-1.patch,v 1.1 2004/06/04 10:32:01 jim Exp $
*/
 
#include <stdio.h>
#include <sys/times.h>
#include <unistd.h>
 
#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;
}
#endif /* _GNU_SOURCE */