1 /*******************************************************************************
2  *  The BYTE UNIX Benchmarks - Release 3
3  *          Module: execl.c   SID: 3.3 5/15/91 19:30:19
4  *
5  *******************************************************************************
6  * Bug reports, patches, comments, suggestions should be sent to:
7  *
8  *	Ben Smith, Rick Grehan or Tom Yager
9  *	ben@bytepb.byte.com   rick_g@bytepb.byte.com   tyager@bytepb.byte.com
10  *
11  *******************************************************************************
12  *  Modification Log:
13  *  $Header: execl.c,v 3.5 87/06/22 15:37:08 kjmcdonell Beta $
14  *  August 28, 1990 - Modified timing routines
15  *  October 22, 1997 - code cleanup to remove ANSI C compiler warnings
16  *                     Andy Kahn <kahn@zk3.dec.com>
17  *
18  ******************************************************************************/
19 /*
20  *  Execing
21  *
22  */
23 char SCCSid[] = "@(#) @(#)execl.c:3.3 -- 5/15/91 19:30:19";
24 
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <unistd.h>
28 #include <sys/types.h>
29 
30 char	bss[8*1024];	/* something worthwhile */
31 
32 #define main dummy
33 
34 #include "big.c"        /* some real code */
35 
36 #undef main
37 
38 /* added by BYTE */
39 char *getenv();
40 
41 
main(argc,argv)42 int main(argc, argv)	/* the real program */
43 int	argc;
44 char	*argv[];
45 {
46 	unsigned long iter = 0;
47 	char *ptr;
48 	char *fullpath;
49 	int 	duration;
50 	char	count_str[12], start_str[24], path_str[256], *dur_str;
51 	time_t	start_time, this_time;
52 
53 #ifdef DEBUG
54 	int count;
55 	for(count = 0; count < argc; ++ count)
56 		printf("%s ",argv[count]);
57 		printf("\n");
58 #endif
59 	if (argc < 2)
60 		{
61 		fprintf(stderr, "Usage: %s duration\n", argv[0]);
62 		exit(1);
63 		}
64 
65 
66 	duration = atoi(argv[1]);
67 	if (duration > 0)
68 		/* the first invocation */
69 		{
70 		dur_str = argv[1];
71 		if((ptr = getenv("UB_BINDIR")) != NULL)
72 			sprintf(path_str,"%s/execl",ptr);
73 		fullpath=path_str;
74 		time(&start_time);
75 		}
76 	else  /* one of those execl'd invocations */
77 		{
78 		/* real duration follow the phoney null duration */
79 		duration = atoi(argv[2]);
80 		dur_str = argv[2];
81 		iter = (unsigned long)atoi(argv[3]); /* where are we now ? */
82 		sscanf(argv[4], "%lu", (unsigned long *) &start_time);
83 		fullpath = argv[0];
84 		}
85 
86 	sprintf(count_str, "%lu", ++iter); /* increment the execl counter */
87 	sprintf(start_str, "%lu", (unsigned long) start_time);
88 	time(&this_time);
89 	if (this_time - start_time >= duration) { /* time has run out */
90 		fprintf(stderr, "COUNT|%lu|1|lps\n", iter);
91 		exit(0);
92 		}
93 	execl(fullpath, fullpath, "0", dur_str, count_str, start_str, (void *) 0);
94 	fprintf(stderr, "Exec failed at iteration %lu\n", iter);
95 	perror("Reason");
96 	exit(1);
97 }
98