1--TEST--
2proc_nice() basic behaviour
3--CREDITS--
4Italian PHP TestFest 2009 Cesena 19-20-21 june
5Fabio Fabbrucci (fabbrucci@grupporetina.com)
6Michele Orselli (mo@ideato.it)
7Simone Gentili (sensorario@gmail.com)
8--SKIPIF--
9<?php
10if(!function_exists('proc_nice')) die("skip. proc_nice not available ");
11if(substr(strtoupper(PHP_OS), 0, 3) == 'WIN') die('skip. not for Windows');
12?>
13--FILE--
14<?php
15	function getNice($id)
16	{
17		$res = shell_exec('ps -p ' . $id .' -o "pid,nice"');
18		preg_match('/^\s*\w+\s+\w+\s*(\d+)\s+(\d+)/m', $res, $matches);
19		if (count($matches) > 2)
20			return $matches[2];
21		else
22			return -1;
23	}
24	$delta = 10;
25	$pid = getmypid();
26	$niceBefore = getNice($pid);
27	proc_nice($delta);
28	$niceAfter = getNice($pid);
29	var_dump($niceBefore == ($niceAfter - $delta));
30?>
31--EXPECT--
32bool(true)
33