com php-src: Fixed bug #74849 Process is started as interactive shell in PhpStorm: sapi/cli/php_cli.c win32/console.c win 32/console.h
| From: | Anatol Belski | Date: | Mon, 03 Jul 2017 19:59:31 +0000 |
| Subject: | com php-src: Fixed bug #74849 Process is started as interactive shell in PhpStorm: sapi/cli/php_cli.c win32/console.c win 32/console.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-98305@lists.php.net to get a copy of this message | ||
Commit: 8871d2d12eb6b516d6685a83ca8530af6d1557f8
Author: Anatol Belski <ab@php.net> Mon, 3 Jul 2017 21:58:51 +0200
Parents: 55cd4e859b2d4a405be112452ed76d07ff404c01
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8871d2d12eb6b516d6685a83ca8530af6d1557f8
Log:
Fixed bug #74849 Process is started as interactive shell in PhpStorm
Bugs:
https://bugs.php.net/74849
Changed paths:
M sapi/cli/php_cli.c
M win32/console.c
M win32/console.h
Diff:
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index 07e8a8c..d1fa6a6 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -675,8 +675,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
char *arg_free=NULL, **arg_excp=&arg_free;
char *script_file=NULL, *translated_path = NULL;
#if defined(PHP_WIN32) && !defined(PHP_CLI_WIN32_NO_CONSOLE) && (HAVE_LIBREADLINE
|| HAVE_LIBEDIT) && !defined(COMPILE_DL_READLINE)
- DWORD pl[1];
- int interactive = (GetConsoleProcessList(pl, 1) == 1) && !IsDebuggerPresent();
+ int interactive = php_win32_console_is_own();
#else
int interactive=0;
#endif
diff --git a/win32/console.c b/win32/console.c
index 7883649..07e6afa 100644
--- a/win32/console.c
+++ b/win32/console.c
@@ -91,3 +91,15 @@ PHP_WINUTIL_API BOOL php_win32_console_fileno_set_vt100(zend_long fileno, BOOL e
}
return result;
}
+
+PHP_WINUTIL_API BOOL php_win32_console_is_own(void)
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+ if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) &&
!IsDebuggerPresent()) {
+ return !csbi.dwCursorPosition.X && !csbi.dwCursorPosition.Y;
+ }
+
+ return FALSE;
+}
+
diff --git a/win32/console.h b/win32/console.h
index 0a2213c..ab62a6b 100644
--- a/win32/console.h
+++ b/win32/console.h
@@ -56,4 +56,9 @@ associated to a file descriptor
*/
PHP_WINUTIL_API BOOL php_win32_console_fileno_set_vt100(zend_long fileno, BOOL enable);
+/* Check, whether the program has its own console. If a process was launched
+ through a GUI, it will have it's own console. For more info see
+ http://support.microsoft.com/kb/99115 */
+PHP_WINUTIL_API BOOL php_win32_console_is_own(void);
+
#endif