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