// WithProcessClosed returns a context.Context that is cancelled // after Process p is Closed. It is the equivalent of: // // func WithProcessClosed(ctx context.Context, p goprocess.Process) context.Context { // ctx, cancel := context.WithCancel(ctx) // go func() { // <-p.Closed() // cancel() // }() // return ctx // } // func WithProcessClosed(ctx context.Context, p goprocess.Process) context.Context { ctx, cancel := context.WithCancel(ctx) go func() { <-p.Closed() cancel() }() return ctx }
// OnClosedContext derives a context from a given goprocess that will // be 'Done' when the process is closed func OnClosedContext(p goprocess.Process) context.Context { return &procContext{ done: p.Closed(), which: closed, } }