2
2
* Author: Manoj Ampalam <[email protected] >
3
3
* Primitive shell-host to support parsing of cmd.exe input and async IO redirection
4
4
*
5
+ * Author: Ray Heyes <[email protected] >
6
+ * PTY with ANSI emulation wrapper
7
+ *
5
8
* Copyright (c) 2015 Microsoft Corp.
6
9
* All rights reserved
7
10
*
@@ -807,7 +810,7 @@ DWORD WINAPI ProcessPipes(LPVOID p) {
807
810
/* process data from pipe_in and route appropriately */
808
811
while (1 ) {
809
812
char buf [128 ];
810
- DWORD rd = 0 , wr = 0 , i = 0 ;
813
+ DWORD rd = 0 , wr = 0 , i = -1 ;
811
814
812
815
GOTO_CLEANUP_ON_FALSE (ReadFile (pipe_in , buf , 128 , & rd , NULL ));
813
816
if (!istty ) { /* no tty, just send it accross */
@@ -817,10 +820,15 @@ DWORD WINAPI ProcessPipes(LPVOID p) {
817
820
818
821
bStartup = FALSE;
819
822
820
- while (i < rd ) {
823
+ while (++ i < rd ) {
821
824
822
825
INPUT_RECORD ir ;
823
826
827
+ if (buf [i ] == 3 ) {/*Ctrl+C - Raise Ctrl+C*/
828
+ GenerateConsoleCtrlEvent (CTRL_C_EVENT , childProcessId );
829
+ continue ;
830
+ }
831
+
824
832
if (bAnsi ) {
825
833
ir .EventType = KEY_EVENT ;
826
834
ir .Event .KeyEvent .bKeyDown = TRUE;
@@ -950,7 +958,6 @@ DWORD WINAPI ProcessPipes(LPVOID p) {
950
958
}
951
959
}
952
960
953
- i ++ ;
954
961
}
955
962
}
956
963
@@ -1115,7 +1122,9 @@ int wmain(int ac, wchar_t **av) {
1115
1122
1116
1123
/*TODO - pick this up from system32*/
1117
1124
cmd [0 ] = L'\0' ;
1118
- GOTO_CLEANUP_ON_ERR (wcscat_s (cmd , MAX_PATH , L"cmd.exe" ));
1125
+ if (ac )
1126
+ GOTO_CLEANUP_ON_ERR (wcscat_s (cmd , MAX_PATH , L"cmd.exe" ));
1127
+
1119
1128
ac -- ;
1120
1129
av ++ ;
1121
1130
if (ac )
0 commit comments