[Info-vax] disabling a CTRL/Y ast
Tom Adams
tadamsmar at gmail.com
Thu Jan 7 10:25:08 EST 2016
On Wednesday, January 6, 2016 at 12:22:06 PM UTC-5, Stephen Hoffman wrote:
> On 2016-01-06 16:46:32 +0000, Tom Adams said:
>
> > I want to turn ctrl/y into a noop in certain regions of code and turn
> > ctrl/y into an exit in other regions of code.
>
> Some background: I've posted more than a few replies here in the
> comp.os.vms newsgroup, specifically discussing the particular
> application in question and its general design, and an unfortunate
> aggregation of the UI and the more critical code paths, and your
> understandable preference to avoid restructuring the application code
> through reworking the existing design to block ^Y from arriving within
> the most critical sections of the code.
>
> > I do find that it is necessary to run lib$disable_ctrl at the beginning
> > of the program and lib$enable_ctrl at the end of the program to restore
> > the previous CLI state, but I need to run asts to do the rest.
>
> If you want ASTs in some parts of the code and not in others, then
> you're going to have to wrap those sections appropriately. That's if
> you don't decide to migrate those critical code sections into another
> process context, or related steps. Because beyond the potential for ^Y
> in these sections and the associated issues you're having with the
> image rundown processing in the absence of an EXIT command, other sorts
> of generic application failures ("bugs") or any arriving $forcex calls
> or such activities can potentially still leave the application in an
> indeterminate state.
>
>
>
> --
> Pure Personal Opinion | HoffmanLabs LLC
Here's an example of what I am trying to do that seems to work OK.
I guess a forced exit from a bug could leave the CTRL\Y in
the disabled state at the CLI instead of the original state.
Also, it's possible that someone could define TT to be some terminal
other than the login terminal. VMS leaves all the built-in process
logicals that refer to the login terminal vulnerable to redefinition.
It may be possible to roll your own safe (executive, no_alias) logical
name via a call in syslogin.
Also, I still need to cover the cases where this code runs in a context
where TT is not defined.
implicit none
Include '($libclidef)/list'
integer*4 oldmask,cnt
common oldmask
call lib$disable_ctrl(LIB$M_CLI_CTRLY,oldmask)
call setabort(.true.)
cnt = 3
do while (cnt.gt.0)
cnt = cnt-1
type *,'abort enabled'
call lib$wait(5.0)
call setabort(.false.)
type *, 'abort disabled'
call lib$wait(5.0)
call setabort(.true.)
end do
call lib$enable_ctrl(oldmask,%val(0))
type *,'completed normally'
end
subroutine byebye()
implicit none
integer*4 oldmask
common oldmask
call lib$enable_ctrl(oldmask,%val(0))
type *,'aborted'
call sys$exit(%val(1))
return
end
subroutine setabort(enable)
implicit none
INCLUDE '(LIB$ROUTINES)/LIST'
Include '($iodef)/list'
Include '($libclidef)/list'
logical*4 enable
integer*2 chn
integer*4 s,sys$assign,sys$qiow,iosb(2)
logical*4 first_call /.true./
save first_call
external byebye
s=1
if (first_call) then
first_call = .false.
s=sys$assign ('TT:', chn,,,)
end if
if (enable) then
if (s) s=sys$qiow ( ,
1 %val(chn),
1 %val(IO$_SETMODE .or.
1 IO$M_CTRLYAST),
1 iosb,,,byebye,,,,,)
else
if (s) s=sys$qiow ( ,
1 %val(chn),
1 %val(IO$_SETMODE .or.
1 IO$M_CTRLYAST),
1 iosb,,,%val(0),,,,,)
end if
if (.not.s) call lib$signal(%val(s))
end
More information about the Info-vax
mailing list