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