home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume7 / xdm / patch1.01 / makeconsole.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-08  |  835 b   |  57 lines

  1. #include <fcntl.h>
  2. #include <sys/termios.h>
  3. #include <sys/wait.h>
  4. #define FONT "-adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1"
  5. #include "xdmconsole.h"
  6. #define PTYPROC "/usr/bin/X11/xdmconsole"
  7.  
  8. char *ttydev;
  9. char *ptydev;
  10.  
  11. extern int tty, pty;
  12.  
  13.  
  14. int getttys()
  15. {
  16.     if ((get_pty(&pty)) != 0) return(-1);
  17.     if ((tty=open(ttydev, O_RDWR, 0)) < 0)
  18.     {
  19.         return(-1);
  20.     }
  21.     return(0);
  22. }
  23.  
  24.  
  25.  
  26. int make_console()
  27. {
  28.     int childpid;
  29.  
  30.     if ((childpid=fork())==0)
  31.     {
  32.         close(0);
  33.         dup(pty);
  34.  
  35.         execl(PTYPROC, "console", 0);
  36.     }
  37.     if (ioctl(tty, TIOCCONS, 0) < 0)
  38.     {
  39.         return(-1);
  40.     }
  41.     return(childpid);
  42. }
  43.  
  44. int kill_console(childpid)
  45. int childpid;
  46. {
  47.  
  48. /*
  49.     if (childpid > 20)
  50.         if (kill(childpid, 9) != -1)
  51.             if (wait((union wait *) 0) == -1)
  52.                 perror("console");
  53.   for some reason, this seems to kill xdm totally sometimes (about 1 in 50)
  54. */
  55.  
  56. }
  57.