Years ago, I got very annoyed not being able to 'break in' the middle of a long-running jobstream and start the
debugger. If I could only get to a command line when the terminal was input inhibited!
The only way I could think of interrupting a job was simply by using the System Request key. After looking at the System Request Menu -- and realizing you could send messages to specific message queues from a System Request command line and you could evoke a program whenever a message queue received a message -- I determined it was possible to create a "programmus interruptus" utility that would give me a command line or let me execute debug commands directly.
The result was two CL programs, DOINK and DOINKSTER, and a command handler, also called DOINK. (For lack of a better name.)
The way it works is like this:
- When you create the programs and the command handler, make sure they're all created in the same library and that library is present in your library list.
- At sign-on time, set up your DOINK by typing DOINK at the command line.
- To evoke DOINK, do the following:
-Bring up the System request command
-Enter the following "5 q q" (the
number 5, followed by a space, the
letter q, another space, and another
-The QCMD command entry screen
You can also run OS/400 commands by entering "5 '
How it works
When the DOINK command is executed, the DOINK cpp sets up a special message queue called, simply, Q in the QTEMP library. Then the message queue is changed to call a program when the queue receives a message. The program called is DOINKSTER.
When Q receives a message, it calls DOINKSTER. OS/400 is kind enough to pass the message queue, message queue library, and message key to DOINKSTER. DOINKSTER then pulls the message off the queue. If the message text is simply "q", then QCMD is called. If the message text is something else, then the message text is passed to QCMDEXC, and OS/400 will attempt to execute the message text.
================================== DOINK Command Source ---------------------------------- DOINK: CMD PROMPT('Install ALT-SYSRQS interrupt') ================================== DOINK Command Processing Program ---------------------------------- PGM CRTMSGQ MSGQ(QTEMP/Q) CHGMSGQ MSGQ(QTEMP/Q) DLVRY(*BREAK) + PGM(*LIBL/DOINKSTER) SNDPGMMSG MSG('DOINK installed') + TOPGMQ(*PRV) ENDIT: ENDPGM ================================== DOINKSTER System Request Handler ---------------------------------- /* HANDLE DOINK REQUESTS */ PGM PARM(&MSGQ &MSGQLIB &MSGKEY) DCL VAR(&MSGQ) TYPE(*CHAR) LEN(10) DCL VAR(&MSGQLIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSGKEY) TYPE(*CHAR) LEN(4) DCL VAR(&MSG) TYPE(*CHAR) LEN(80) DCL VAR(&LEN) TYPE(*DEC) + LEN(15 5) VALUE(80) MONMSG MSGID(CPF0000) RCVMSG MSGQ(&MSGQLIB/&MSGQ) + MSGKEY (&MSGKEY) MSG(&MSG) IF COND(&MSG *EQ 'Q') THEN(DO) CALL PGM(QCMD) ENDDO ELSE CMD(DO) CALL PGM(QCMDEXC) PARM(&LEN &MSG) ENDDO ENDIT: ENDPGM