On Wed, 28 Jan 2009, Jakob Westhoff wrote: > I would like to propose a new component to ease the execution of > external processes. > > I created an object oriented execution wrapper some time ago for another > project I am currently working on. After all the positive feedback I got > from different people using this utility I realized this could possibly > an interesting contribution to the eZComponents. I wrote a requirements > document for such a component which you can find attached to this mail. > As you will see from the requirements document. The current > implementation could easily be used as a basis for the creation of a > more sophisticated process handler, which I would like to write.
It looks like a good idea indeed, I've some remarks and comments though to your document: > eZ Components: SystemProcess, Requirements > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > :Author: Jakob Westhoff > :Revision: $Revision: 14 $ > :Date: $Date: 2009-01-28 19:30:31 +0100 (Mi, 28. Jan 2009) $ > > Introduction > ============ > > Description > ----------- > > The SystemProcess component presents a set of features to execute and handle > external applications in an easy and manageable way. It takes care of the > underlying system calls and specialties like different path formatting or > signal handling to provide a platform independent but yet flexible way to work > with external applications. > > Furthermore it automagically escapes the given command or argument parts to > make code injection less easy and ensure correct command execution. > > > Current implementation > ---------------------- > > The currently available implementation provides easy means to handle > synchronous as well as asynchronous program executions using the proc_* > function set from php. It is fully unit tested. At the current development > stage it is does not ensure any cross platform compatibility with windows or > any other system them plain Linux. Nevertheless it should also work on other > \*nix based systems. Because of not taking windows support into account, > currently no way of cross platform path creation is implemented either. > > It is available at:: > > svn://svn.pureenergy.cc/systemProcess > > > Requirements > ============ > > The SystemProcess component needs to fulfill the following requirements from > the current point of view: > > Execution > --------- > > - Provide an easy but yet effective way of executing external processes, > retrieving their output after they finished. (Synchronous execution) > > - Provide means to read from the file descriptors (STDOUT, STDERR, custom > descriptors) an executed process provides during while it is currently > running. (Asynchronous execution) > > - Provide a string representation of the built shell command without > necessarily executing it. > > - Receive the probably non zero exit codes after process execution finished. > > - Send arbitrary POSIX signals to an asynchronously running process. (This can > obviously not be done on windows systems.) > > - Terminate a currently running process. This is only feasible for > asynchronously running processes where such operations can be triggered > while > the process is running. It would also be good to have an overview of which processes are running as "children" so that an interface can be presented that allows you to watch the status (running, alive, dead, stopped, terminated) and perhaps kill them. Another possibility perhaps could be to spawn in one go multiple processed as "worker threads". > Design goals > ============ > > The workflow of a creating a SystemProcess object applying certain arguments > as > well as options to it and finally spawning the process should be intuitive as > possible. The best way to achieve such an intuitive API would be to design it > having the fluent interface pattern in mind. The used interface should look > something like this:: > > new ezcSystemProcess( 'echo' )->argument( 'foo' )->execute(); Method chaining can not be done with "new classname", so it has to be: $p = new ezcSystemProcess( 'echo' ); $p->argument( 'foo' )->execute(); regards, Derick -- Derick Rethans eZ components Product Manager eZ systems | http://ez.no -- Components mailing list Components@lists.ez.no http://lists.ez.no/mailman/listinfo/components