Project

General

Profile

Bug #3531

Windows ChUI mode issue for CTRL-BREAK and CTRL-C pressing

Added by Eugenie Lyzenko about 6 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
03/21/2018
Due date:
% Done:

100%

billable:
No
vendor_id:
GCD
case_num:

History

#1 Updated by Eugenie Lyzenko about 6 years ago

The expected reaction for both CTRL-BREAk and CTRL-C pressing is to reload the current client session for Windows ChUI mode. Currently the FWD implementation does not work as expected.

#3 Updated by Eugenie Lyzenko about 6 years ago

The fix approach:

1. We need to add signal(SIGBREAK, sigintHandler) the same way as we do for signal(SIGINT, sigintHandler) and signal(SIGBREAK, SIG_IGN) as we do for signal(SIGINT, SIG_IGN) in signals_win.c source. This will intercepts both CTRL-C and CTRL-BREAK events for ChUI and suppress the screen garbage display on ChUI console for CTRL-BREAK.

2. Then we need to add CtrlHandler function for terminal_win.c source to be able to insert our handler for CTRL-BREAK. This is possible with MS API SetConsoleCtrlHandler(CtrlHandler, TRUE) where the CtrlHandler can be:

BOOL WINAPI CtrlHandler(DWORD fdwCtrlType) 
{ 
   INPUT_RECORD inWrite;
   DWORD numberOfRecWritten = 0;

   switch(fdwCtrlType) 
   {
      // Intercepts CTRL-BREAK and simulate CTRL-C key 
      case CTRL_BREAK_EVENT:
         // simulate CTRL-C
         inWrite.EventType = KEY_EVENT;
         inWrite.Event.KeyEvent.bKeyDown = JNI_TRUE;
         inWrite.Event.KeyEvent.uChar.AsciiChar = 3; // ASCII code for CTRL-C
         inWrite.Event.KeyEvent.dwControlKeyState = LEFT_CTRL_PRESSED; // Let the left CTRL key be down
         // insert 1 artificial key into console buffer
         WriteConsoleInput(hConsoleIn, &inWrite, 1, &numberOfRecWritten);
         // suppress the rest of CTRL-BREAK processing
         return TRUE; 

      default: 
         return FALSE; 
   }
}

The code inserts artificial CTRL-C key into console input buffer. And that's it. The console native reader code (in the terminal_win.c) will read artificial CTRL-C pass it to Java side and client will restart after CTRL-BREAK as for CTRL-C event. This is what 4GL does in ChUI mode.

#4 Updated by Greg Shah about 6 years ago

I like it. Please put it into 3488a.

#5 Updated by Eugenie Lyzenko about 6 years ago

Greg Shah wrote:

I like it. Please put it into 3488a.

Task branch 3488a has been updated for review to revision 11252.

This is the native code fix for CTRL-BREAK/CTRL-C processing in Windows ChUI.

#6 Updated by Greg Shah about 6 years ago

Code Review Task Branch 3488a Revision 11252

This is really good work!

#7 Updated by Eugenie Lyzenko about 6 years ago

Finished first main round for 3488a rev 11251. The result is pretty good considering start time. Restart testing with DB restore and new 11252 revision. Combined results must be consistent because 11252 has only Windows related changes.

#8 Updated by Eugenie Lyzenko about 6 years ago

The main part completed for 11252 revision. Clean run in one cycle, hopefully. Waiting for CTRL-C to be done.

Can I merge the 3488a branch into trunk if testing will be OK?

#9 Updated by Greg Shah about 6 years ago

Eric will coordinate the order of merge to trunk. He is trying to get 3261a into trunk first. You will not need to re-test, just rebase and then merge.

#10 Updated by Eugenie Lyzenko about 6 years ago

Greg Shah wrote:

Eric will coordinate the order of merge to trunk. He is trying to get 3261a into trunk first. You will not need to re-test, just rebase and then merge.

OK.

#11 Updated by Eugenie Lyzenko about 6 years ago

Testing completed. No regressions found so far. The results can be seen in 3488a_11252_54eebfb_20180322_evl.zip.

Eric, please let me know when I can rebase 3488a and merge into trunk.

Also I guess the tasks 3488 and 3531 can be closed.

#12 Updated by Eric Faulhaber about 6 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

Task branch 3488a was merged to trunk revision 11239.

Also available in: Atom PDF