Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: ken.cunefare@me.gatech.edu (Kenneth A. Cunefare)
Subject: Help with trapping unix signals-DEC Fortran/OSF
Date: Tue, 21 Feb 95 08:28:37 GMT	[thread overview]
Message-ID: <ken.cunefare.1143742957B@news.gatech.edu> (raw)

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



                 reply	other threads:[~1995-02-21  8:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox