Skip to content

Commit 8871d2d

Browse files
committed
Fixed bug #74849 Process is started as interactive shell in PhpStorm
1 parent 55cd4e8 commit 8871d2d

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

sapi/cli/php_cli.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
675675
char *arg_free=NULL, **arg_excp=&arg_free;
676676
char *script_file=NULL, *translated_path = NULL;
677677
#if defined(PHP_WIN32) && !defined(PHP_CLI_WIN32_NO_CONSOLE) && (HAVE_LIBREADLINE || HAVE_LIBEDIT) && !defined(COMPILE_DL_READLINE)
678-
DWORD pl[1];
679-
int interactive = (GetConsoleProcessList(pl, 1) == 1) && !IsDebuggerPresent();
678+
int interactive = php_win32_console_is_own();
680679
#else
681680
int interactive=0;
682681
#endif

win32/console.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,15 @@ PHP_WINUTIL_API BOOL php_win32_console_fileno_set_vt100(zend_long fileno, BOOL e
9191
}
9292
return result;
9393
}
94+
95+
PHP_WINUTIL_API BOOL php_win32_console_is_own(void)
96+
{
97+
CONSOLE_SCREEN_BUFFER_INFO csbi;
98+
99+
if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) && !IsDebuggerPresent()) {
100+
return !csbi.dwCursorPosition.X && !csbi.dwCursorPosition.Y;
101+
}
102+
103+
return FALSE;
104+
}
105+

win32/console.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,9 @@ associated to a file descriptor
5656
*/
5757
PHP_WINUTIL_API BOOL php_win32_console_fileno_set_vt100(zend_long fileno, BOOL enable);
5858

59+
/* Check, whether the program has its own console. If a process was launched
60+
through a GUI, it will have it's own console. For more info see
61+
http://support.microsoft.com/kb/99115 */
62+
PHP_WINUTIL_API BOOL php_win32_console_is_own(void);
63+
5964
#endif

0 commit comments

Comments
 (0)