[Chicago] Popen/subprocess/Poll Question.
Pete
pfein at pobox.com
Thu Jul 22 22:36:44 CEST 2010
On Jul 22, 2010, at 11:57 AM, Samir Faci wrote:
>> On Thu, Jul 22, 2010 at 10:28 AM, Martin Maney <maney at two14.net> wrote:
>>>
>>> On Thu, Jul 22, 2010 at 09:55:24AM -0500, Samir Faci wrote:
>>>> I'm running a process that's usually takes a while.... (in the best
>>>> case scenario a few hours... going on days occasionally)
>>>>
>>>> I'm presuming I need to spawn a thread for the process so it doesn't
>>>> block.
>>>
>>>
>>> There's an Anciente Unixe command that does this very thing, named
>>> "tee". Just sayin'
>
> sure. tee would work. But I have a nice logger library that adds
> those handy timestamps.. which helps me figure out when things broke
Hmm, you could dup() the child's stdout to a pipe and have the parent read off it... I think that would let you do what you're trying to. Though that's a good bit more work, as you'd need to manage the fork/exec/etc. yourself.
If the lack of timestamps on your lines is getting you down, pipe the child's output through a simple script that prepends a timestamp (awk version: http://stackoverflow.com/questions/21564/is-there-a-unix-utility-to-prepend-timestamps-to-lines-of-text)
But yeah, just use tee. ;-)
More information about the Chicago
mailing list