⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 time.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
字号:
#ifndef lintstatic	char *sccsid = "@(#)time.c	4.5 (Berkeley) 7/1/83";#endif/* * time */#include <stdio.h>#include <signal.h>#include <sys/types.h>#include <sys/time.h>#include <sys/resource.h>main(argc, argv)	int argc;	char **argv;{	int status;	register int p;	struct timeval before, after;	struct rusage ru;	if (argc<=1)		exit(0);	gettimeofday(&before, 0);	p = fork();	if (p < 0) {		perror("time");		exit(1);	}	if (p == 0) {		execvp(argv[1], &argv[1]);		perror(argv[1]);		exit(1);	}	signal(SIGINT, SIG_IGN);	signal(SIGQUIT, SIG_IGN);	while (wait3(&status, 0, &ru) != p)		;	gettimeofday(&after, 0);	if ((status&0377) != 0)		fprintf(stderr, "Command terminated abnormally.\n");	after.tv_sec -= before.tv_sec;	after.tv_usec -= before.tv_usec;	if (after.tv_usec < 0)		after.tv_sec--, after.tv_usec += 1000000;	printt("real", &after);	printt("user", &ru.ru_utime);	printt("sys ", &ru.ru_stime);	fprintf(stderr, "\n");	exit (status>>8);}printt(s, tv)	char *s;	struct timeval *tv;{	fprintf(stderr, "%9d.%01d %s ", tv->tv_sec, tv->tv_usec/100000, s);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -