PTY i/o queues, DSUSP & select()

Viktor Dukhovni viktor at fine.Princeton.EDU
Tue Feb 28 12:43:38 AEST 1989


	Does someone why I can fill the input queue of a PTY
(in cbreak mode with DSUSP enabled and set to ^Y,  all other chars disabled),
with ^Y's,  
	ioctl(master,FIONBIO,&on) ;
	while(write(master,"\031",1) == 1)
		;
but never detect that these are being "read"

	if ((pid=fork()) == 0) {
		(*signal)(SIGTSTP,SIG_IGN) ;
		for(;;) 
			read(slave,&c,1) ;
	} else {
		mask = 1 << master ;
		/*  Wait till we can write more,  i.e.
		    want to detect child reading slave */
		select(32,0,&mask,0,0) ;  /*  Never returns */
		/*  Kill child when select returns */
		kill(SIGHUP,pid) ;
		/*  Wait for it */
		wait(&status) ;
	}

I want to be able to start a child process for which I do not have source
(you guessed it /etc/dump :-( ),  and kill it as soon as it reads the slave
pty.  I can catch reads by the immedeate child,  just by writing a single
^Y and waiting for it to stop,  but sometimes,  the slave pty is read
by the children of /etc/dump  (one child per volume,  write errors lead
to requests for help from the operator by the child dump).  These
also get stopped,  but then get woken up by an alarm and continue,
so waiting for their parent is not enough,  I want to be able to detect
as quickly as possible a read by *any* descendent.  Select might have done
the trick,  but the queue does not seem to drain when ^Y is "read".

	Any suggestions/explanations welcome.

-- 
	Viktor Dukhovni <viktor%fine at princeton.edu>



More information about the Comp.unix.wizards mailing list