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 ");
11?>
12--FILE--
13<?php
14	function getNice($id)
15	{
16		$res = shell_exec('ps -p ' . $id .' -o "pid,nice"');
17		preg_match('/^\s*\w+\s+\w+\s*(\d+)\s+(\d+)/m', $res, $matches);
18		if (count($matches) > 2)
19			return $matches[2];
20		else
21			return -1;
22	}
23	$delta = 10;
24	$pid = getmypid();
25	$niceBefore = getNice($pid);
26	proc_nice($delta);
27	$niceAfter = getNice($pid);
28	var_dump($niceBefore == ($niceAfter - $delta));
29?>
30--EXPECTF--
31bool(true)
32