diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2024-11-03 15:14:35 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2024-11-03 20:12:47 +0900 |
| commit | 19495eb9bbfa874647e7bc69e0fdff49d68b1dcf (patch) | |
| tree | feec000483143382c365d5d68dbce41860af9b4c /src/core.go | |
| parent | bacc8609ee22fb9bbe34dc812ecb6075f4e58007 (diff) | |
| download | fzf-19495eb9bbfa874647e7bc69e0fdff49d68b1dcf.tar.gz | |
Remove possible races (#4070)
Diffstat (limited to 'src/core.go')
| -rw-r--r-- | src/core.go | 10 |
1 files changed, 7 insertions, 3 deletions
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 |
