GRASS Programmer's Manual
6.4.2(2012)
|
00001 00002 /**************************************************************** 00003 this program runs its arguments as a commmand. it essentially 00004 does what the sh would do to look for the command. if / occurs in 00005 the command it runs it as is, otherwise it search the PATH 00006 variable. care is taken to preserve the PATH variable that is 00007 passed (as part of the environment) to the command being invoked. 00008 00009 the signals SIGINT and SIGQUIT are set to the default action 00010 before running the command. 00011 00012 This program is needed because the GIS shell must ignore 00013 interrupts when it runs the user's shell. There is no way to tell 00014 the user's shell to re-activate interrupts in shell-ese. 00015 ****************************************************************/ 00016 00017 #include <stdio.h> 00018 #include <stdlib.h> 00019 #include <signal.h> 00020 #include <unistd.h> 00021 #include "local_proto.h" 00022 00023 int main(int argc, char *argv[]) 00024 { 00025 signal(SIGINT, SIG_DFL); 00026 #ifndef __MINGW32__ 00027 signal(SIGQUIT, SIG_DFL); 00028 #endif 00029 00030 argc--; 00031 argv++; 00032 if (argc <= 0) 00033 exit(1); 00034 00035 execvp(argv[0], argv); 00036 fprintf(stderr, "%s: Command not found\n", argv[0]); 00037 exit(127); 00038 00039 exit(0); 00040 }