supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: Charlie Brady <charlieb-supervision@budge.apana.org.au>
Cc: supervision@list.skarnet.org
Subject: Re: Runit on tty1
Date: Wed, 5 Jul 2006 11:08:02 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.61.0607051100380.9807@e-smith.charlieb.ott.istop.com> (raw)
In-Reply-To: <449C4064.6050504@langside.org.uk>


On Fri, 23 Jun 2006, Richard A Downing FBCS CITP wrote:

> I have just built a new system (glibc-2.4, gcc04.1.1, linux-2.6.17.1)
> with runit-1.5.1.
> This seems to be quite stable except that tty1 does not accept ctrl-c -
> indeed if /etc/runit/ctrlaltdel exists, this is run when ctrl-c is
> pressed on tty1 (and causes a reboot as expected).

What are you running on tty1 and how is it started?

> Another effect, also only on tty1 is that a long output can be
> interrupted by a replay of earlier output, this can be recovered by
> switching to another tty and back - nothing is in fact list, it's just
> the screen output.

I'm sorry, I cannot parse that sentence and I do not know exactly what you 
are describing. Could you try again?

> Further investigation reveals that runit, as process 1, is marked by
> ps-ef as being on tty1 and the bash process started by getty-1 is marked
> as ? for it's TTY.

Is getty-1 a runit supervised process? If so, what is its run script?

>  I suspect this is the problem, as it is quite unlike
> my other runit-based systems.
> There are no errors in the runsvdir proctitle.

I've used the following program to start a well behaved shell on tty1 
under runit supervision. I wouldn't be surprised if not all the magic 
invocations are necessary:

#include <termios.h>
#include <sys/fcntl.h>
#include <sys/ioctl.h>
#include <errno.h>

main(argc, argv)
int     argc;
char    *argv[];
{
     int fd;
     ++argv;
     struct termios tty;

     if (! *argv)
     {
         exit(1);
     }

     /* Clean up */
     ioctl(0, TIOCNOTTY, 0);
     close(0);
     close(1);
     close(2);
     setsid();

     /* Reopen console */
     if ((fd = open("/dev/tts/1", O_RDWR)) < 0) {
             return errno;
     }
     dup2(fd, 0);
     dup2(fd, 1);
     dup2(fd, 2);

     ioctl(0, TIOCSCTTY, 1);
     tcsetpgrp(0, getpgrp());

     /* Set terminal settings to reasonable defaults */
     tcgetattr(0, &tty);

     /* set control chars */
     tty.c_cc[VINTR]  = 3;       /* C-c */
     tty.c_cc[VQUIT]  = 28;      /* C-\ */
     tty.c_cc[VERASE] = 127; /* C-? */
     tty.c_cc[VKILL]  = 21;      /* C-u */
     tty.c_cc[VEOF]   = 4;       /* C-d */
     tty.c_cc[VSTART] = 17;      /* C-q */
     tty.c_cc[VSTOP]  = 19;      /* C-s */
     tty.c_cc[VSUSP]  = 26;      /* C-z */

     /* use line dicipline 0 */
     tty.c_line = 0;

     /* Make it be sane */
     tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD;
     tty.c_cflag |= CREAD|HUPCL|CLOCAL;

     /* input modes */
     tty.c_iflag = ICRNL | IXON | IXOFF;

     /* output modes */
     tty.c_oflag = OPOST | ONLCR;

     /* local modes */
     tty.c_lflag =
             ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE | IEXTEN;

     tcsetattr(0, TCSANOW, &tty);

     execvp(*argv, argv);
     exit(3);
}



  parent reply	other threads:[~2006-07-05 15:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-23 19:26 Richard A Downing FBCS CITP
2006-06-30  9:10 ` Richard Downing
2006-06-30  9:27   ` Gerrit Pape
2006-07-05 15:08 ` Charlie Brady [this message]
2006-07-05 16:11   ` Milan P. Stanic
2006-07-06  7:02     ` Richard Downing
2006-09-21  5:59 Zachary Kotlarek
2006-09-21 13:57 ` Richard Downing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.61.0607051100380.9807@e-smith.charlieb.ott.istop.com \
    --to=charlieb-supervision@budge.apana.org.au \
    --cc=supervision@list.skarnet.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).