1: # include   <stdio.h>
   2: 
   3: # include   "../ingres.h"
   4: # include   "../aux.h"
   5: # include   "../unix.h"
   6: # include   "monitor.h"
   7: 
   8: /*
   9: **  CALL UNIX SHELL
  10: **
  11: **	The UNIX shell is called.  Shell() first tries to call an
  12: **	alternate shell defined by the macro {shell}, and if it fails
  13: **	calls /bin/sh.
  14: **
  15: **	If an argument is supplied, it is a shell file which is
  16: **	supplied to the shell.
  17: **
  18: **	Uses trace flag 7
  19: */
  20: 
  21: shell()
  22: {
  23:     register int    i;
  24:     register char   *p;
  25:     register char   *shellfile;
  26:     char        *getfilename();
  27:     char        *macro();
  28: 
  29:     shellfile = getfilename();
  30:     if (*shellfile == 0)
  31:         shellfile = 0;
  32: 
  33:     fclose(Qryiop);
  34:     if ((Xwaitpid = fork()) == -1)
  35:         syserr("shell: fork");
  36:     if (Xwaitpid == 0)
  37:     {
  38:         setuid(getuid());
  39: #		ifndef xB_UNIX
  40:         setgid(getgid());
  41: #		endif
  42:         for (i = 3; i < MAXFILES; i++)
  43:             close(i);
  44:         p = macro("{shell}");
  45: #		ifdef xMTR3
  46:         tTfp(7, 0, "{shell} = '%o'\n", p);
  47: #		endif
  48:         if (p != 0)
  49:         {
  50:             execl(p, p, shellfile, Qbname, 0);
  51:             printf("Cannot call %s; using /bin/sh\n", p);
  52:         }
  53:         execl("/bin/sh", "sh", shellfile, Qbname, 0);
  54:         syserr("shell: exec");
  55:     }
  56: 
  57:     if (Nodayfile >= 0)
  58:         printf(">>shell\n");
  59:     /* wait for shell to complete */
  60:     xwait();
  61: }

Defined functions

shell defined in line 21; used 1 times
Last modified: 1995-02-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2616
Valid CSS Valid XHTML 1.0 Strict