Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - tinit issue/fix: (1 Item)
   
tinit issue/fix  
I am not sure that this is the right forum for this, but I think I have identified a bug/deficiency in tinit.  I also 
believe that I have a fix for it.

The basic problem:  If a device listed in /etc/config/ttys does not exist at the time tinit starts, it will (probably) 
never supervise that device ever.  On the other hand, if the device exists at the time tinit starts and then disappears 
(the resource manager quits/dies, etc.,) then the device will be "taken over" again when it is recreated.

I believe that the core of the problem is this code (in the start() function):
<snip>
pid_t start(struct tty_entry *ttp, int session) {
	char				*argv[MAXARGS];
	char				*src, *dst, *cmd;
	char				buf[100];
	struct inheritance	inherit;
	struct termios		tios;
	int					fds[3] = {0, 1, 2}, i;

	close(0);
	if(open(ttp->devname, O_RDWR) == -1)
		return(-1); 

</snip>

I believe that the solution is to replace the last two lines of the snippet with:
	if(open(ttp->devname, O_RDWR) == -1) {
                ttp->pid = -1; 
		return( ttp->pid ); 
        }

The rationale is pretty simple.  The "tty->pid == -1" condition is the trigger for tinit to retry opening the device and
 starting the controlling program.  If the device has never been opened, the tty->pid field is left uninitialized, 
probably will not contain -1, and will never ever be retried again.

I may have misunderstood something, but I believe that this is what is happening (as seen on my system).