File: run.c

package info (click to toggle)
grass 8.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 277,040 kB
  • sloc: ansic: 460,798; python: 227,732; cpp: 42,026; sh: 11,262; makefile: 7,007; xml: 3,637; sql: 968; lex: 520; javascript: 484; yacc: 450; asm: 387; perl: 157; sed: 25; objc: 6; ruby: 4
file content (39 lines) | stat: -rw-r--r-- 1,150 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/****************************************************************
this program runs its arguments as  a  command.  it  essentially
does what the sh would do to look for the command. if / occurs in
the command it runs it  as  is,  otherwise  it  search  the  PATH
variable.  care  is  taken  to preserve the PATH variable that is
passed (as part of the environment) to the command being invoked.

the signals SIGINT and SIGQUIT are  set  to  the  default  action
before running the command.

This  program  is  needed  because  the  GIS  shell  must  ignore
interrupts when it runs the user's shell. There is no way to tell
the user's shell to re-activate interrupts in shell-ese.
****************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include "local_proto.h"

int main(int argc, char *argv[])
{
    signal(SIGINT, SIG_DFL);
#ifndef __MINGW32__
    signal(SIGQUIT, SIG_DFL);
#endif

    argc--;
    argv++;
    if (argc <= 0)
        exit(1);

    execvp(argv[0], argv);
    fprintf(stderr, "%s: Command not found\n", argv[0]);
    exit(127);

    exit(0);
}