1--TEST-- 2Check cli_process_title support on Unix 3--SKIPIF-- 4<?php 5if (PHP_SAPI !== "cli") 6 die("skip cli process title not available in non-cli SAPI"); 7if (!PHP_CLI_PROCESS_TITLE) 8 die("skip process title not available (disabled or unsupported)"); 9if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') 10 die("skip Not for Windows"); 11 12exec("ps -p 1", $output, $exit_code); 13if ($exit_code !== 0) { 14 die("skip ps -p is not available"); 15} 16?> 17--FILE-- 18<?php 19echo "*** Testing setting the process title ***\n"; 20 21$set_title = $original_title = uniqid("title", true); 22$pid = getmypid(); 23 24if (cli_set_process_title($original_title) === true) 25 echo "Successfully set title\n"; 26 27$ps_process_title_field = "command"; 28if (strtoupper(substr(PHP_OS, 0, 3)) == "AIX") 29{ 30 $ps_process_title_field = "args"; 31} 32$ps_output = shell_exec("ps -p $pid -o $ps_process_title_field | tail -n 1"); 33 34if ($ps_output === null) 35{ 36 echo "ps failed\n"; 37 die(); 38} 39 40$loaded_title = trim($ps_output); 41if (strpos(strtoupper(substr(PHP_OS, 0, 13)), "BSD") !== false) 42{ 43 // Fix up title for BSD 44 $set_title = "php: $original_title (php)"; 45} 46 47if ($loaded_title == $set_title) 48 echo "Successfully verified title using ps\n"; 49else 50 echo "Actually loaded from ps: $loaded_title\n"; 51 52$read_title = cli_get_process_title(); 53if ($read_title == $original_title) 54 echo "Successfully verified title using get\n"; 55else 56 echo "Actually loaded from get: $read_title\n"; 57 58?> 59--EXPECT-- 60*** Testing setting the process title *** 61Successfully set title 62Successfully verified title using ps 63Successfully verified title using get 64