[ From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 22-DEC-1990 10:34:42.59  To:	MRGATE::"ARISIA::EVERHART" CC:	( Subj:	Re: XtAddInput and VMS DEC Windows  * Received:  by crdgw1.ge.com (5.57/GE 1.80)) 	 id AA24091; Sat, 22 Dec 90 10:08:37 EST Y Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Sat, 22 DEC 90 07:01:17 PST , Received: by ucbvax.Berkeley.EDU (5.63/1.42)* 	id AA25519; Sat, 22 Dec 90 06:41:44 -08009 Received: from USENET by ucbvax.Berkeley.EDU with netnews . 	for info-vax@kl.sri.com (info-vax@kl.sri.com); 	(contact usenet@ucbvax.Berkeley.EDU if you have questions)  Date: 22 Dec 90 07:33:20 GMT$ From: cbmvax!xmws!baxter@rutgers.eduC Organization: Integrated Solutions, Incorporated.  Valley Forge, PA + Subject: Re: XtAddInput and VMS DEC Windows # Message-Id: <52.2772c5f0@xmws.uucp> , References: <1990Nov20.184509.3252@objy.com># Sender: info-vax-request@kl.sri.com  To: info-vax@kl.sri.com   a In article <1990Nov20.184509.3252@objy.com>, ricks@prefect.objy.com (Rick L. Spickelmier) writes: = > I'm trying to get XtAddInput to work on VMS with the input  < > coming from a pipe connected to a subprocess (created with 	stuff deleted: > I just hang...  Does anybody use XtAddInput under VMS?     Yes   & > Is it with a subprocess via pipes?     No    D I did a presentation on this at DECUS six months ago... get ahold ofM the VAX Sig session notes from someone for the New Orleans Decus last spring.   A You CANN'T DO IT with PIPES...  Which are ONLY SIMULATED on VMS.    O You need control of read completion from the mailbox that the pipe really is...   H You _MUST_ do this in a VMS specific way, i.e. You MUST use the VMS QIO K Mechansim and you must do it asynchonously... so that XtMainEventLoop will   still have control...   F The source argument to XtAddInput is really a VMS event flag number... THIS is the key!!!!!  H In your QIO read completion ast routine you must Set the event flag whenI you have read something... This causes Xt to calback your XtInputCallback J routine... which can then process the data is "real" time as apposed to at/ AST level.  NB: Xt on VMS is NOT AST reentrant    I In the simplest case: (where you let the OS buffer the IO, and you do not  do internal io buffering)   @ 	your Application Q's a read, and returns to the main eventloop.  A 	The AST read completion routine reads the data and sets the efn   	passed to XtAddInput.    + 	Xt then calls the XtInputCallback routine. = 	The XtInputCallback routine should clear the efn.   When the . 	data is processed, it should Q the next read.  C The code can be ISOLATED to a small IO module that is VMS specific.   G Read the IO users guide on using mailboxes... this will tell you how to F setup the interprocess communication using mailboxes... (which is what a pipe really is on VMS)  = Code fragments for reading follow... its not complete but you  should get the idea...  C #define cleared_bit_was_clear( bp, flgs ) ( _BBCCI( (bp), (flgs) )) C #define set_bit_was_set( bp, flgs )       ( _BBSSI( (bp), (flgs) ))   / static long int read_ast ( IOBuffer * bufferP )  {      long int ret_stat;.     sys$synch( read_QIO_efn, &bufferP->iosb );     sys$setef ( Xt_read_efn  ); /     put_on_Q_tail( bufferP, full_Q, ret_stat ); 6     cleared_bit_was_clear( ReadIsPending, &IO_flags ); }    long int StartReadIO() {      long int ret_stat;     long int io_function;      IOBuffer * bufferP;   @     if ( set_bit_was_set( ReadIsPending, &IO_flags ) ) return 0;     else     {           GetIOBuffer( &bufferP );         ret_stat = sys$qio (#                        read_QIO_efn "                        ,IO_channel$                        ,IO$_READVBLK&                        ,&bufferP->iosb9                        ,&read_ast     /* ast routine.r */ 6                        ,bufferP         /* astprm.v */&                        ,bufferP->dataP+                        ,MaximumBufferLength                         ,0                         ,0                         ,0                         ,0                     );   D         _ExitIfOSError( ret_stat, "SYS$QIO in IO:read_IO_started" );     } 
     return 1;  }  #undef ROUTINE  $ XtInputCallbackProc XtInputHandler( 1 	caddr_t userdata, int * Source, XtInputId * id )       /* we ignore the arguements,;      * this routine does the work in real time not ast time       */  {      int ret_stat;      char * cp;     IOBuffer * bufferP;   )     ret_stat = sys$clref ( Xt_read_efn ); 5     ret_stat = remove_from_Q_head( full_Q, bufferP );      switch ( ret_stat )      { '           case Q_INTERLOCK_FAILED     : K                 ExitWithMessage ( "Q_INTERLOCK_FAILED in XtInputHandler" ); 5           case Q_WAS_EMPTY            : return False; '           case REMQ_WERE_MORE_ENTRIES : F                         sys$setef ( Xt_read_efn ); /* call me again */     }   [     _ExitIfOSError( bufferP->iosb.condition ,"Bad iosb.condition in XtInputCallbackProc" ); 5     /* NOW extract data from buffer and process it */      (*theProtocolDecodeProc)( 5         bufferP->dataP, bufferP->iosb.transfer_cnt );        /* now setup the next IO */ /     put_on_Q_tail( bufferP, free_Q, ret_stat );      StartReadIO();     return False;  }   