From:	SMTP%"RELAY-INFO-VAX@CRVAX.SRI.COM"  1-SEP-1993 11:09:28.41
To:	EVERHART
CC:	
Subj:	Re: ctrl-c,y capture in vaxC

Date: Wed, 01 Sep 1993 15:48:55 +0100
From: Arne Vajhøj <ARNE@kopc.hhs.dk>
Subject: Re: ctrl-c,y capture in vaxC
To: tapani.tiensuu@VTT.FI, INFO-VAX@SRI.COM
Message-id: <01H2FTXUO9V69LVN1Y@kopc.hhs.dk>
X-VMS-To: KOPC::IN%"tapani.tiensuu@VTT.FI"
X-VMS-Cc: IN::"INFO-VAX@SRI.COM"
MIME-version: 1.0
Content-type: TEXT/PLAIN; CHARSET=ISO-8859-1
Content-transfer-encoding: 8BIT

> A friend of mine has tried a couple of days to capture ctlr-c and
> ctrl-y in vax c program. Ie. establish an interrupt handler.
> In vain.

Small C example:

#include <stdio.h>
#include <descrip.h>
#include <iodef.h>
#include <ssdef.h>
#include <libclidef.h>

long sys$assign();
long sys$qiow();
long sys$dassgn();

long lib$disable_ctrl();
long lib$enable_ctrl();

long catcher()
{
   long y = LIB$M_CLI_CTRLY;
   printf("You choosed CTRL/Y\n");
   lib$enable_ctrl(&y);
   exit(SS$_ABORT);
}

main()
{
   long y = LIB$M_CLI_CTRLY;
   short chan;
   $DESCRIPTOR(ttdesc,"TT:");
   lib$disable_ctrl(&y);
   sys$assign(&ttdesc,&chan,0,0);
   sys$qiow(0,chan,IO$_SETMODE|IO$M_CTRLYAST,0,0,0,&catcher,0,0,0,0,0);
   printf("Press RETURN or CTRL/Y\n");
   getchar();
   printf("You choosed RETURN\n");
   sys$dassgn(chan);
   lib$enable_ctrl(&y);
   exit(SS$_NORMAL);
}

Hope it helps !

                                                          Arne

Arne Vajhøj                             local DECNET:  KO::ARNE
Computer Department                     PSI:           PSI%238310013040::ARNE
Business School of Southern Denmark     Internet:      ARNE@KO.HHS.DK


