Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
ZendX_Console_Process_Unix allows you to spawn a class as a separated process


 array
                 $_internalIpcData= 'array()'
array
                 $_internalIpcData= 'array()'
                A data structure to hold data for Inter Process Communications
array()Details

 boolean
                 $_ipcIsOkay= ''
boolean
                 $_ipcIsOkay= ''
                Is Shared Memory Area OK? If not, the start() method will block.
Otherwise we'll have a running child without any communication channel.


 boolean
                 $_isChild= 'false'
boolean
                 $_isChild= 'false'
                Wether we are into child process or not
falseDetails

 boolean
                 $_isRunning= 'false'
boolean
                 $_isRunning= 'false'
                Whether the process is yet forked or not
falseDetails

 __construct(
          integer $puid
              =
              null, integer $guid
              =
              null, integer $umask
              =
              null
          )
        
        :
          void
__construct(
          integer $puid
              =
              null, integer $guid
              =
              null, integer $umask
              =
              null
          )
        
        :
          voidConstructor method
Allocates a new pseudo-thread object. Optionally, set a PUID, a GUID and a UMASK for the child process. This also initialize Shared Memory Segments for process communications.
| Name | Type | Description | 
|---|---|---|
| $puid | integer | |
| $guid | integer | |
| $umask | integer | 
| Exception | Description | 
|---|---|
| \ZendX_Console_Process_Exception | When running on windows | 
| \ZendX_Console_Process_Exception | When running in web enviroment | 
| \ZendX_Console_Process_Exception | When shmop_* functions don't exist | 
| \ZendX_Console_Process_Exception | When pcntl_* functions don't exist | 
| \ZendX_Console_Process_Exception | When posix_* functions don't exist | 


 _callCallbackMethod(
          string $methodName, array $argList
              =
              array(), string $type
              =
              self::VOID_METHOD
          )
        
        :
          mixed
_callCallbackMethod(
          string $methodName, array $argList
              =
              array(), string $type
              =
              self::VOID_METHOD
          )
        
        :
          mixedThis is called from within the parent; all the communication stuff is done here.
| Name | Type | Description | 
|---|---|---|
| $methodName | string | |
| $argList | array | |
| $type | string | 
| Type | Description | 
|---|---|
| mixed | 


 _createIpcSegment(
          
          )
        
        :
          boolean
_createIpcSegment(
          
          )
        
        :
          booleanCreate an IPC segment
| Type | Description | 
|---|---|
| boolean | 
| Exception | Description | 
|---|---|
| \ZendX_Console_Process_Exception | When SHM segment can't be created | 


 _createIpcSemaphore(
          
          )
        
        :
          boolean
_createIpcSemaphore(
          
          )
        
        :
          booleanCreate IPC semaphore
| Type | Description | 
|---|---|
| boolean | 
| Exception | Description | 
|---|---|
| \ZendX_Console_Process_Exception | When semaphore can't be created | 


 _readFromIpcSegment(
          
          )
        
        :
          void
_readFromIpcSegment(
          
          )
        
        :
          voidRead data from IPC segment
| Exception | Description | 
|---|---|
| \ZendX_Console_Process_Exception | When writing of SHM segment fails | 


 _setAlive(
          
          )
        
        :
          void
_setAlive(
          
          )
        
        :
          voidSet a pseudo-thread property that can be read from parent process in order to know the child activity.
Practical usage requires that child process calls this method at regular time intervals; parent will use the getLastAlive() method to know the elapsed time since the last pseudo-thread life signals...


 _sigHandler(
          integer $signo
          )
        
        :
          void
_sigHandler(
          integer $signo
          )
        
        :
          voidThis is the signal handler that makes the communications between client and server possible.
| Name | Type | Description | 
|---|---|---|
| $signo | integer | 


 _writeToIpcSegment(
          
          )
        
        :
          void
_writeToIpcSegment(
          
          )
        
        :
          voidWrite data to IPC segment
| Exception | Description | 
|---|---|
| \ZendX_Console_Process_Exception | When writing of SHM segment fails | 


 _writeVariable(
          string $name, mixed $value
          )
        
        :
          void
_writeVariable(
          string $name, mixed $value
          )
        
        :
          voidAcutally Write a variable to the shared memory segment
| Name | Type | Description | 
|---|---|---|
| $name | string | |
| $value | mixed | 


 getLastAlive(
          
          )
        
        :
          integer
getLastAlive(
          
          )
        
        :
          integerRead the time elapsed since the last child setAlive() call.
This method is useful because often we have a pseudo-thread pool and we need to know each pseudo-thread status. If the child executes the setAlive() method, the parent with getLastAlive() can know that child is alive.
| Type | Description | 
|---|---|
| integer | 


 getVariable(
          string $name
          )
        
        :
          mixed
getVariable(
          string $name
          )
        
        :
          mixedGet a variable from the shared memory segment. Returns NULL if the variable doesn't exist.
| Name | Type | Description | 
|---|---|---|
| $name | string | 
| Type | Description | 
|---|---|
| mixed | 


 isRunning(
          
          )
        
        :
          boolean
isRunning(
          
          )
        
        :
          booleanTest if the pseudo-thread is already started.
| Type | Description | 
|---|---|
| boolean | 


 setVariable(
          string $name, mixed $value
          )
        
        :
          void
setVariable(
          string $name, mixed $value
          )
        
        :
          voidSet a variable into the shared memory segment, so that it can accessed both from the parent and from the child process. Variable names beginning with underlines are only permitted to interal functions.
| Name | Type | Description | 
|---|---|---|
| $name | string | |
| $value | mixed | 
| Exception | Description | 
|---|---|
| \ZendX_Console_Process_Exception | When an invalid variable name is supplied | 


 start(
          
          )
        
        :
          void
start(
          
          )
        
        :
          voidCauses this pseudo-thread to begin parallel execution.
This method first checks of all the Shared Memory Segment. If okay, it forks the child process, attaches signal handler and returns immediatly. The status is set to running, and a PID is assigned. The result is that two pseudo-threads are running concurrently: the current thread (which returns from the call to the start() method) and the other thread (which executes its run() method).
| Exception | Description | 
|---|---|
| \ZendX_Console_Process_Exception | When SHM segments can't be created | 
| \ZendX_Console_Process_Exception | When process forking fails |