Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!rutgers!clyde!cbatt!ihnp4!ucbvax!RELAY.CS.NET!HELLER%cs.umass.edu From: HELLER%cs.umass.edu@RELAY.CS.NET (Stride 440 User) Newsgroups: mod.computers.vax Subject: RE: VMS, FORTRAN & CTRL-c AST Message-ID: <8611151312.AA28958@ucbvax.Berkeley.EDU> Date: Fri, 14-Nov-86 08:05:00 EST Article-I.D.: ucbvax.8611151312.AA28958 Posted: Fri Nov 14 08:05:00 1986 Date-Received: Sun, 16-Nov-86 01:33:23 EST Sender: daemon@ucbvax.BERKELEY.EDU Organization: The ARPA Internet Lines: 37 Approved: info-vax@sri-kl.arpa The problem is FORTRAN I/O is non-"atomic", that is a FORTRAN statement like: accept 10,x,y,x does not generate a single call to some FOR$blah routine, but in fact something like 5 calls to FOR$blah routines. This sequence is really a "critical section" of sorts. At least for you purposes it is. If your ^C handler bobs along in this critical section, you will end up with a pending I/O operation on the unit number (-3 in the case of accept) associatiated with the interupted I/O statement. The next I/O request on that unit number can't be processed, and fails with a recursive I/O operation. That unit number is now dead. The only thing you can do now is exit back to DCL and start over. So much for FORTRAN I/O. What you have to do is poll for ^C. Your ^C handler simply sets a logical variable in a common block. This variable is tested at "reasonable" points in the code, and a non-local exit is done at these points. (Probably by doing a lib$signal with some made up signal which is caught by your condition handler, which does a sys$unwind. There is a routine called FOR$IO_END (something like that), but you can only call this if there is an I/O operation in progress AND if you know the unit # of the pending I/O. There is no universal "clean up any I/O, if any" type function. Once a unit has been bashed with a "Recursive I/O operation", it is completely dead, with no recovery posible. The only safe thing you can do is the ^C polling method. Also, if you setup an out-of-band AST (like DCL's ^T) to report status, DON'T do FORTRAN I/O in it, use SYS$QIOW only, using SYS$FAO(L) or C's sprintf, not FORTRAN's ENCODE to format the message buffer(s). Robert Heller ARPANet: Heller@UMass-CS.CSNET BITNET: Heller@UMass.BITNET BIX: Heller GEnie: RHeller FidoNet: 101/27 (Dave's Fido, Gardner MA)