So the problem is that init steals the controlling terminal when it's
finished running the rcS script.

I attach a little program "thief" that can be used to demonstrate the
same effect -

1. launch splashy
2. run "thief /dev/console"

Splashy now gets eof on all reads from the keyboard, and can't set the
terminal back to text mode.

(I can't quite figure out why this problem only occurs when splashy is
run from the ramdisk.)

Looks like a pretty hard one to fix.

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/wait.h>


int main (int argc, char **argv) {

	int child;
	int status;

	if (argc != 2) {
		fprintf (stderr, "usage %s tty\n", *argv);
		exit (1);
	}

	if ((child = fork ()) < 0) {
		perror ("fork");
		exit (1);
	}
	else if (!child) {
		int fd;
		fprintf (stderr, "Stealing %s\n", argv[1]);
		setsid ();
		if ((fd = open (argv[1], O_RDWR + O_NOCTTY)) == -1) {
			perror ("open");
			exit (1);
		}
		if (ioctl (fd, TIOCSCTTY, 1) == -1) {
			perror ("TIOCSCTTY");
			exit (1);
		}
		exit (0);
	}
	else {
		int status;
		waitpid (child, &status, 0);
		if (status != 0) {
			fprintf (stderr, "failed\n");
		}
	}
	return 0;
}

Reply via email to