run.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. the signals SIGINT and SIGQUIT are set to the default action
  8. before running the command.
  9. This program is needed because the GIS shell must ignore
  10. interrupts when it runs the user's shell. There is no way to tell
  11. the user's shell to re-activate interrupts in shell-ese.
  12. ****************************************************************/
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <signal.h>
  16. #include <unistd.h>
  17. #include "local_proto.h"
  18. int main(int argc, char *argv[])
  19. {
  20. signal(SIGINT, SIG_DFL);
  21. #ifndef __MINGW32__
  22. signal(SIGQUIT, SIG_DFL);
  23. #endif
  24. argc--;
  25. argv++;
  26. if (argc <= 0)
  27. exit(1);
  28. execvp(argv[0], argv);
  29. fprintf(stderr, "%s: Command not found\n", argv[0]);
  30. exit(127);
  31. exit(0);
  32. }