home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / monitor / edit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-18  |  998 b   |  54 lines

  1. # include    "monitor.h"
  2. # include    <ingres.h>
  3. # include    <aux.h>
  4. # include    <opsys.h>
  5.  
  6. /*
  7. **  CALL TEXT EDITOR
  8. **
  9. **    The UNIX text editor is called.  The actual call is to
  10. **    the macro {editor}.  If that fails, /bin/ed is called.
  11. **    This routine suppressed the autoclear function.
  12. **
  13. **    Uses trace flag 4
  14. */
  15.  
  16. edit()
  17. {
  18.     register int    i;
  19.     register char    *p;
  20.     register char    *editfile;
  21.     extern char    *getfilenm(), *macro();
  22.  
  23.     editfile = getfilenm();
  24.     if (*editfile == 0)
  25.         editfile = Qbname;
  26.  
  27.     Autoclear = 0;
  28.     fclose(Qryiop);
  29.  
  30.     /* FORK SENTRY PROCESS & INVOKE THE EDITOR */
  31.     if ((Xwaitpid = fork()) < 0)
  32.         syserr("edit: fork");
  33.     if (Xwaitpid == 0)
  34.     {
  35.         setuid(getuid());
  36.         setgid(getgid());
  37.         for (i = 3; i < NOFILE; i++)
  38.             close(i);
  39.         p = macro("{editor}");
  40.         if (p != 0)
  41.         {
  42.             execl(p, p, editfile, 0);
  43.             printf("Cannot call %s; using /bin/ed\n", p);
  44.         }
  45.         execl("/bin/ed", "ed", editfile, 0);
  46.         syserr("edit: exec");
  47.     }
  48.  
  49.     /* WAIT FOR SENTRY TO DIE */
  50.     if (Nodayfile >= 0)
  51.         printf(">>ed\n");
  52.     xwait();
  53. }
  54.