File: cli_process_title_unix.phpt

package info (click to toggle)
php5 5.6.33%2Bdfsg-0%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 157,872 kB
  • sloc: ansic: 756,065; php: 22,030; sh: 12,311; cpp: 8,771; xml: 6,179; yacc: 1,564; exp: 1,514; makefile: 1,467; pascal: 1,147; awk: 538; perl: 315; sql: 22
file content (54 lines) | stat: -rw-r--r-- 1,276 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
--TEST--
Check cli_process_title support on Unix
--SKIPIF--
<?php
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
  die("skip");
?>
--FILE--
<?php
echo "*** Testing setting the process title ***\n";

$set_title = $original_title = uniqid("title", true);
$pid = getmypid();

if (cli_set_process_title($original_title) === true)
  echo "Successfully set title\n";

$ps_process_title_field = "command";
if (strtoupper(substr(PHP_OS, 0, 3)) == "AIX")
{
  $ps_process_title_field = "args";
}
$ps_output = shell_exec("ps -p $pid -o $ps_process_title_field | tail -n 1");

if ($ps_output === null)
{
  echo "ps failed\n";
  die();
}

$loaded_title = trim($ps_output);
if (strpos(strtoupper(substr(PHP_OS, 0, 13)), "BSD") !== false)
{
  // Fix up title for BSD
  $set_title = "php: $original_title (php)";
}

if ($loaded_title == $set_title)
  echo "Successfully verified title using ps\n";
else
  echo "Actually loaded from ps: $loaded_title\n";

$read_title = cli_get_process_title();
if ($read_title == $original_title)
  echo "Successfully verified title using get\n";
else
  echo "Actually loaded from get: $read_title\n";

?>
--EXPECTF--
*** Testing setting the process title ***
Successfully set title
Successfully verified title using ps
Successfully verified title using get