* @ingroup Maintenance
*/
class ForkController {
- var $children = array();
- var $termReceived = false;
- var $flags = 0, $procsToStart = 0;
+ protected $children = array(), $childNumber = 0;
+ protected $termReceived = false;
+ protected $flags = 0, $procsToStart = 0;
- static $restartableSignals = array(
+ protected static $restartableSignals = array(
SIGFPE,
SIGILL,
SIGSEGV,
if ( function_exists( 'pcntl_signal_dispatch' ) ) {
pcntl_signal_dispatch();
} else {
- declare (ticks=1) { $status = $status; }
+ declare( ticks = 1 ) {
+ $status = $status;
+ }
}
// Respond to TERM signal
if ( $this->termReceived ) {
return 'done';
}
+ /**
+ * Get the number of the child currently running. Note, this
+ * is not the pid, but rather which of the total number of children
+ * we are
+ * @return int
+ */
+ public function getChildNumber() {
+ return $this->childNumber;
+ }
+
protected function prepareEnvironment() {
global $wgMemc;
// Don't share DB, storage, or memcached connections
if ( !$pid ) {
$this->initChild();
+ $this->childNumber = $i;
return 'child';
} else {
// This is the parent process