From 19495eb9bbfa874647e7bc69e0fdff49d68b1dcf Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 3 Nov 2024 15:14:35 +0900 Subject: Remove possible races (#4070) --- src/core.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/core.go') diff --git a/src/core.go b/src/core.go index a4527227..89f40ceb 100644 --- a/src/core.go +++ b/src/core.go @@ -172,7 +172,9 @@ func Run(opts *Options) (int, error) { return chunkList.Push(data) }, eventBox, executor, opts.ReadZero, opts.Filter == nil) - go reader.ReadSource(opts.Input, opts.WalkerRoot, opts.WalkerOpts, opts.WalkerSkip, initialReload, initialEnv) + readyChan := make(chan bool) + go reader.ReadSource(opts.Input, opts.WalkerRoot, opts.WalkerOpts, opts.WalkerSkip, initialReload, initialEnv, readyChan) + <-readyChan } // Matcher @@ -224,7 +226,7 @@ func Run(opts *Options) (int, error) { } return false }, eventBox, executor, opts.ReadZero, false) - reader.ReadSource(opts.Input, opts.WalkerRoot, opts.WalkerOpts, opts.WalkerSkip, initialReload, initialEnv) + reader.ReadSource(opts.Input, opts.WalkerRoot, opts.WalkerOpts, opts.WalkerSkip, initialReload, initialEnv, nil) } else { eventBox.Unwatch(EvtReadNew) eventBox.WaitFor(EvtReadFin) @@ -299,7 +301,9 @@ func Run(opts *Options) (int, error) { itemIndex = 0 inputRevision.bumpMajor() header = make([]string, 0, opts.HeaderLines) - reader.restart(command, environ) + readyChan := make(chan bool) + go reader.restart(command, environ, readyChan) + <-readyChan } exitCode := ExitOk -- cgit v1.2.3