Weirdness in hook execution logger

Tim Penhey tim.penhey at canonical.com
Mon Apr 8 00:25:58 UTC 2013


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



More information about the Juju-dev mailing list