]> granicus.if.org Git - php/commitdiff
Combine conditions for the automatic interactive console activation
authorAnatol Belski <ab@php.net>
Mon, 24 Jul 2017 12:47:32 +0000 (14:47 +0200)
committerAnatol Belski <ab@php.net>
Mon, 24 Jul 2017 12:47:32 +0000 (14:47 +0200)
as with bug #74979 it seems to have regressions which were not
present before.

win32/console.c

index c321a37023f2ac4575d5434d3cf485f7ed757ac0..0d52fd12d878a978f2dcd8c736b0491a7c9762d1 100644 (file)
@@ -94,10 +94,18 @@ PHP_WINUTIL_API BOOL php_win32_console_fileno_set_vt100(zend_long fileno, BOOL e
 
 PHP_WINUTIL_API BOOL php_win32_console_is_own(void)
 {/*{{{*/
-       CONSOLE_SCREEN_BUFFER_INFO csbi;
+       if (!IsDebuggerPresent()) {
+               CONSOLE_SCREEN_BUFFER_INFO csbi;
+               DWORD pl[1];
+               BOOL ret0 = FALSE, ret1 = FALSE;
 
-       if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) && !IsDebuggerPresent()) {
-               return !csbi.dwCursorPosition.X && !csbi.dwCursorPosition.Y;
+               if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) {
+                       ret0 = !csbi.dwCursorPosition.X && !csbi.dwCursorPosition.Y;
+               }
+
+               ret1 = GetConsoleProcessList(pl, 1) == 1;
+
+               return ret0 && ret1;
        }
 
        return FALSE;