Fwd: Weirdness in hook execution logger

roger peppe roger.peppe at canonical.com
Mon Apr 8 15:18:18 UTC 2013


---------- Forwarded message ----------
From: roger peppe <roger.peppe at canonical.com>
Date: 8 April 2013 08:56
Subject: Re: Weirdness in hook execution logger
To: Tim Penhey <tim.penhey at canonical.com>


On 8 April 2013 01:25, Tim Penhey <tim.penhey at canonical.com> wrote:
> Hi All,
>
> Was reading some code today and came across the following:
>
> in worker/uniter/context.go, in method:
>
> func (ctx *HookContext) RunHook(hookName, charmDir, toolsDir, socketPath
> string) error {
>
> we have the following
>
>         outReader, outWriter, err := os.Pipe()
>         // [snippity]
>         go logger.run()
>         err = ps.Start()
>         outWriter.Close()
>         if err == nil {
>                 err = ps.Wait()
>         }
>         logger.stop()
>
> Now here it looks as if we are closing the writer part of the pipe
> before the process has finished executing.  This looks suspicious to me,
> and my first thought is that something is wrong.
>
> Is this a bug?  Am I missing something?
>
> If this isn't a bug, what should a comment say before hand so the next
> person who looks at this code doesn't wonder the same thing.
>
> However, my first thought still is that this is wrong, but if I'm wrong,
> I'd like to know why, and better now than in a code review.
>
> Cheers,
> Tim

unix pipes work fine like that.

if i run (cat foo | wc) the cat process might very well close its
output before wc has started running.



More information about the Juju-dev mailing list