Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Fortran 90 Compiler for HP-UX: Fortran 90 Programmer's Guide > Chapter 5 Using the ON statement

Trapping +Ctrl-C trap interrupts

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

A +Ctrl-C interrupt can occur during the following circumstances:

  • When the user enters the interrupt code from the terminal while the program is running or awaiting input

  • During the execution of a PAUSE statement

The trap procedure for a +Ctrl-C interrupt must have no formal arguments. The interrupt code is the character defined by the HP-UX stty(1) command for the intr parameter. The system default for intr is +Ctrl-C.

You can use the +Ctrl-C form of the ON statement to handle the interrupt signal 2. In the following example, when an interrupt occurs, the program reports status information on standard output, assuring the user that the program is still at work in the DO loop. The program uses the ON statement to set the action for a +Ctrl-C interrupt to be the call to the trap handler status:

PROGRAM main
COMMON i
ON CONTROLC CALL status

DO i = 1, 100000
... ! Long computation
END DO
END

SUBROUTINE status
COMMON i
PRINT *, "Currently on iteration ", i
END SUBROUTINE status

When this program is run, a +Ctrl-C interrupt causes the status routine to be called, which prints the iteration count. The program then resumes executing the DO loop.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.