/*
 * Issue the special Sun ioctl making our pty the system console
 * For this to work, some other process must already have the given
 * pseudo-tty open
 */
#include <stdio.h>
#include <sys/types.h>
#include <sys/termios.h>

main(argc,argv)
int argc;
char *argv[];
{
   int rc;
   int fd;

   if (argc != 2) {
      printf("sunConsole: usage is 'sunConsole <pseudo-tty name>'\n");
      exit(1);
   }
   fd = open(argv[1],2);
   if (fd < 0) {
      printf("Error opening pseudo-tty.\n");
      exit(1);
   }
   rc = ioctl(fd,TIOCCONS,NULL);
   if (rc >= 0)
      printf("System console changed.\n");
   else printf("Error changing system console.\n");
   close(fd);
   exit(0);
}
