@@ -105,13 +105,17 @@ extern char** environ;
105
105
#define PS_PADDING ' '
106
106
#endif
107
107
108
- #ifndef PS_USE_CLOBBER_ARGV
108
+ #ifdef PS_USE_WIN32
109
+ static char windows_error_details [64 ];
110
+ static char ps_buffer [MAX_PATH ];
111
+ static const size_t ps_buffer_size = MAX_PATH ;
112
+ #elif PS_USE_CLOBBER_ARGV
113
+ static char * ps_buffer ; /* will point to argv area */
114
+ static size_t ps_buffer_size ; /* space determined at run time */
115
+ #else
109
116
#define PS_BUFFER_SIZE 256
110
117
static char ps_buffer [PS_BUFFER_SIZE ];
111
118
static const size_t ps_buffer_size = PS_BUFFER_SIZE ;
112
- #else
113
- static char * ps_buffer ; /* will point to argv area */
114
- static size_t ps_buffer_size ; /* space determined at run time */
115
119
#endif
116
120
117
121
static size_t ps_buffer_cur_len ; /* actual string length in ps_buffer */
@@ -297,6 +301,12 @@ const char* ps_title_errno(int rc)
297
301
298
302
case PS_TITLE_BUFFER_NOT_AVAILABLE :
299
303
return "Buffer not contiguous" ;
304
+
305
+ #ifdef PS_USE_WIN32
306
+ case PS_TITLE_WINDOWS_ERROR :
307
+ sprintf (windows_error_details , "Windows error code: %d" , GetLastError ());
308
+ return windows_error_details ;
309
+ #endif
300
310
}
301
311
302
312
return "Unknown error code" ;
@@ -348,20 +358,8 @@ int set_ps_title(const char* title)
348
358
349
359
#ifdef PS_USE_WIN32
350
360
{
351
- /*
352
- * Win32 does not support showing any changed arguments. To make it at
353
- * all possible to track which backend is doing what, we create a
354
- * named object that can be viewed with for example Process Explorer.
355
- */
356
- static HANDLE ident_handle = INVALID_HANDLE_VALUE ;
357
- char name [PS_BUFFER_SIZE + 32 ];
358
-
359
- if (ident_handle != INVALID_HANDLE_VALUE )
360
- CloseHandle (ident_handle );
361
-
362
- sprintf (name , "php-process(%d): %s" , _getpid (), ps_buffer );
363
-
364
- ident_handle = CreateEvent (NULL , TRUE, FALSE, name );
361
+ if (!SetConsoleTitle (ps_buffer ))
362
+ return PS_TITLE_WINDOWS_ERROR ;
365
363
}
366
364
#endif /* PS_USE_WIN32 */
367
365
@@ -374,12 +372,16 @@ int set_ps_title(const char* title)
374
372
* length into *displen.
375
373
* The return code indicates the error.
376
374
*/
377
- int get_ps_title (int * displen , const char * * string )
375
+ int get_ps_title (size_t * displen , const char * * string )
378
376
{
379
377
int rc = is_ps_title_available ();
380
378
if (rc != PS_TITLE_SUCCESS )
381
379
return rc ;
382
380
381
+ #ifdef PS_USE_WIN32
382
+ if (!(ps_buffer_cur_len = GetConsoleTitle (ps_buffer , ps_buffer_size )))
383
+ return PS_TITLE_WINDOWS_ERROR ;
384
+ #endif
383
385
* displen = ps_buffer_cur_len ;
384
386
* string = ps_buffer ;
385
387
return PS_TITLE_SUCCESS ;
0 commit comments