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