1
2 /****************************************************************
3 this program runs its arguments as a command. it essentially
4 does what the sh would do to look for the command. if / occurs in
5 the command it runs it as is, otherwise it search the PATH
6 variable. care is taken to preserve the PATH variable that is
7 passed (as part of the environment) to the command being invoked.
8
9 the signals SIGINT and SIGQUIT are set to the default action
10 before running the command.
11
12 This program is needed because the GIS shell must ignore
13 interrupts when it runs the user's shell. There is no way to tell
14 the user's shell to re-activate interrupts in shell-ese.
15 ****************************************************************/
16
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <signal.h>
20 #include <unistd.h>
21 #include "local_proto.h"
22
main(int argc,char * argv[])23 int main(int argc, char *argv[])
24 {
25 signal(SIGINT, SIG_DFL);
26 #ifndef __MINGW32__
27 signal(SIGQUIT, SIG_DFL);
28 #endif
29
30 argc--;
31 argv++;
32 if (argc <= 0)
33 exit(1);
34
35 execvp(argv[0], argv);
36 fprintf(stderr, "%s: Command not found\n", argv[0]);
37 exit(127);
38
39 exit(0);
40 }
41