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_output = shell_exec("ps -p $pid -o command | tail -n 1");
19
20if ($ps_output === null)
21{
22  echo "ps failed\n";
23  die();
24}
25
26$loaded_title = trim($ps_output);
27if (strpos(strtoupper(substr(PHP_OS, 0, 13)), "BSD") !== false)
28{
29  // Fix up title for BSD
30  $set_title = "php: $original_title (php)";
31}
32
33if ($loaded_title == $set_title)
34  echo "Successfully verified title using ps\n";
35else
36  echo "Actually loaded from ps: $loaded_title\n";
37
38$read_title = cli_get_process_title();
39if ($read_title == $original_title)
40  echo "Successfully verified title using get\n";
41else
42  echo "Actually loaded from get: $read_title\n";
43
44?>
45--EXPECTF--
46*** Testing setting the process title ***
47Successfully set title
48Successfully verified title using ps
49Successfully verified title using get
50