From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,416ccff5fc4bd75d,start X-Google-Attributes: gidfee84,public X-Google-Thread: 1094ba,416ccff5fc4bd75d,start X-Google-Attributes: gid1094ba,public X-Google-Thread: 1164f8,416ccff5fc4bd75d,start X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1995-02-21 12:45:01 PST Path: nntp.gmd.de!newsserver.jvnc.net!yale.edu!yale!zip.eecs.umich.edu!newshost.marcam.com!usc!cs.utexas.edu!swrinde!gatech!gt-news!news!ken.cunefare From: ken.cunefare@me.gatech.edu (Kenneth A. Cunefare) Newsgroups: comp.lang.fortran,comp.sys.dec,comp.unix.osf.osf1 Subject: Help with trapping unix signals-DEC Fortran/OSF Followup-To: comp.lang.fortran Date: Tue, 21 Feb 95 08:28:37 GMT Organization: Georgia Tech Message-ID: NNTP-Posting-Host: kcunefare.me.gatech.edu X-Newsreader: VersaTerm Link v1.1.3 Xref: nntp.gmd.de comp.lang.fortran:17597 comp.sys.dec:21718 comp.unix.osf.osf1:7784 Consider the following code scraps, from various places in a rather large program. The intent of the code is: 1) Enter a loop at a known point in the code. While in this loop, an external shell script will send the STOP signal to the code, putting it to sleep. The shell performs a number of functions, and then sends the CONT signal to the program. 2) On receipt of the CONT signal, the signal handler MYHANDLER changes the flag controlling the loop, such that the program con now proceed beyond the loop. The problem: If I don't have the write statement in the loop, the program never recognizes that the variable RUNFLAG has changed state, and stays in the loop forever. I do know that the flag is by changed in the signal handler. I have tried a number of different evaluations/tests in the loop, but the only thing that gets it to work is the bailing-wire-and-chewing-gum fix of having the write statement in there. The question: Why will this code not work without the write statement in the loop? I'm using Fortra 77 on a DEC Alpha 3000/600, with OSF V3.0 (Rev. 347). In the main program: LOGICAL RUNFLAG COMMON /NASA0/ RUNFLAG EXTERNAL MYHANDLER C DIRECT THE HANDLER ROUTINE FOR CONT TO MYHANDLER IRETURN=SIGNAL(19, MYHANDLER, -1) In a subroutine to the main program: LOGICAL RUNFLAG COMMON /NASA0/ RUNFLAG 5 CONTINUE WRITE(60,*) 'IN THE LOOP' CALL FLUSH(60) IF (.NOT.RUNFLAG) GOTO 5 The MYHANDLER routine: SUBROUTINE MYHANDLER(ISIGNUM) INTEGER ISIGNUM CHARACTER*80 LINE CHARACTER*8 SIGTIME LOGICAL RUNFLAG COMMON /NASA0/ RUNFLAG CALL TIME(SIGTIME) WRITE(61,12) SIGTIME,ISIGNUM 12 FORMAT(' AT ',A8,' PROGRAM RECIEVED SIGNAL ',I4) RUNFLAG=.TRUE. WRITE(61,*) 'RUNFLAG is now ', RUNFLAG CLOSE(61) RETURN END Dr. Kenneth A. Cunefare, Assistant Professor Georgia Institute of Technology ken.cunefare@me.gatech.edu