[asterisk-dev] [Code Review] Capture CLI output

Tilghman Lesher tlesher at digium.com
Fri May 7 21:28:52 CDT 2010



> On 2010-05-07 16:28:03, pabelanger wrote:
> > Talking with Russell, he would like to see the output more _realtime_, similar to how runtests.py handles 'tee' to the log file.  However, I can see to figure out a clean way to accomplish this.

You're going to need to first use pipe to generate a pair of pipe ends, fork, connect the stdout of the child process to the input pipe, and exec the command, similar to the way that we currently fork child processes for AGI or MOH mpg123.  It's actually identical to the way that system() works, except that the wait() on the child process isn't executed until later, usually in a signal handler for SIGCHLD.  This ensures that both processes execute concurrently, and the child feeds line-by-line output to the original script, which allows it to react more immediately to the output.


- Tilghman


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/653/#review1984
-----------------------------------------------------------


On 2010-05-07 16:26:10, pabelanger wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/653/
> -----------------------------------------------------------
> 
> (Updated 2010-05-07 16:26:10)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> I need to capture the CLI output for a test case I am working on for loading / unloading modules.
> 
> After talking with Russell, this is the best I could come up with.
> 
> 
> Diffs
> -----
> 
>   /asterisk/trunk/lib/python/asterisk/asterisk.py 288 
> 
> Diff: https://reviewboard.asterisk.org/r/653/diff
> 
> 
> Testing
> -------
> 
> Local development / QA box.
> 
> 
> Thanks,
> 
> pabelanger
> 
>




More information about the asterisk-dev mailing list