source: trunk/gcc/boehm-gc/if_not_there.c

Last change on this file was 2, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 660 bytes
Line 
1/* Conditionally execute a command based if the file argv[1] doesn't exist */
2/* Except for execvp, we stick to ANSI C. */
3# include "private/gcconfig.h"
4# include <stdio.h>
5# include <stdlib.h>
6# include <unistd.h>
7
8int main(argc, argv, envp)
9int argc;
10char ** argv;
11char ** envp;
12{
13 FILE * f;
14 if (argc < 3) goto Usage;
15 if ((f = fopen(argv[1], "rb")) != 0
16 || (f = fopen(argv[1], "r")) != 0) {
17 fclose(f);
18 return(0);
19 }
20 printf("^^^^Starting command^^^^\n");
21 fflush(stdout);
22 execvp(argv[2], argv+2);
23 exit(1);
24
25Usage:
26 fprintf(stderr, "Usage: %s file_name command\n", argv[0]);
27 return(1);
28}
29
Note: See TracBrowser for help on using the repository browser.