OrionUserland
Barry Importing existing Orion Userland 19aefaa (2 years, 4 months ago)#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/times.h> #include <sys/wait.h> #include <errno.h> /* Main function */ int main(int argc, char *argv[]) { pid_t pid; Times tms; clock_t r0, r1; int status, ret = 0; if (argc < 2) return 0; r0 = times(&tms); pid = fork(); if (!pid) { execv(argv[1], argv + 1); printf("exec: %s: ", argv[1]); perror(NULL); exit(EXIT_FAILURE); } waitpid(pid, &status, 0); if ((r1 = times(&tms)) == (clock_t) -1) { perror("times"); exit(EXIT_FAILURE); } printf("\nreal %dms\nuser %dms\nsys %dms\n", (r1 - r0), tms.cutime, tms.cstime); // printf("\nreal %f\nuser %f\nsys %f\n", // (r1 - r0) / (double) 1000, // tms.cutime / (double) 1000, // tms.cstime / (double) 1000); return 0; }