GRASS GIS 8 Programmer's Manual 8.2.0(2022)-exported
run.c
Go to the documentation of this file.
1
2/****************************************************************
3this program runs its arguments as a command. it essentially
4does what the sh would do to look for the command. if / occurs in
5the command it runs it as is, otherwise it search the PATH
6variable. care is taken to preserve the PATH variable that is
7passed (as part of the environment) to the command being invoked.
8
9the signals SIGINT and SIGQUIT are set to the default action
10before running the command.
11
12This program is needed because the GIS shell must ignore
13interrupts when it runs the user's shell. There is no way to tell
14the 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
23int 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}
int main(int argc, char *argv[])
Definition: run.c:23