summaryrefslogtreecommitdiff
path: root/src/core.go
diff options
context:
space:
mode:
authorCharlie Vieth <charlie.vieth@gmail.com>2024-04-13 01:58:11 -0400
committerGitHub <noreply@github.com>2024-04-13 14:58:11 +0900
commit3c877c504b6102daf5dcc1083b1f1a7db88d304c (patch)
tree7072b889071948a6bfb6d980d43367745a37490f /src/core.go
parent892d1acccb705e5547be1b3b6fad8b6d480c290b (diff)
downloadfzf-3c877c504b6102daf5dcc1083b1f1a7db88d304c.tar.gz
Enable profiling options when 'pprof' tag is set (#2813)
This commit enables cpu, mem, block, and mutex profling of the FZF executable. To support flushing the profiles at program exit it adds util.AtExit to register "at exit" functions and mandates that util.Exit is used instead of os.Exit to stop the program. Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
Diffstat (limited to 'src/core.go')
-rw-r--r--src/core.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/core.go b/src/core.go
index ae5e58bf..8253c49e 100644
--- a/src/core.go
+++ b/src/core.go
@@ -3,7 +3,6 @@ package fzf
import (
"fmt"
- "os"
"time"
"unsafe"
@@ -29,6 +28,8 @@ func sbytes(data string) []byte {
// Run starts fzf
func Run(opts *Options, version string, revision string) {
+ defer util.RunAtExitFuncs()
+
sort := opts.Sort > 0
sortCriteria = opts.Criteria
@@ -38,7 +39,7 @@ func Run(opts *Options, version string, revision string) {
} else {
fmt.Println(version)
}
- os.Exit(exitOk)
+ util.Exit(exitOk)
}
// Event channel
@@ -189,9 +190,9 @@ func Run(opts *Options, version string, revision string) {
}
}
if found {
- os.Exit(exitOk)
+ util.Exit(exitOk)
}
- os.Exit(exitNoMatch)
+ util.Exit(exitNoMatch)
}
// Synchronous search
@@ -270,7 +271,7 @@ func Run(opts *Options, version string, revision string) {
if reading {
reader.terminate()
}
- os.Exit(value.(int))
+ util.Exit(value.(int))
case EvtReadNew, EvtReadFin:
if evt == EvtReadFin && nextCommand != nil {
restart(*nextCommand, nextEnviron)
@@ -372,9 +373,9 @@ func Run(opts *Options, version string, revision string) {
opts.Printer(val.Get(i).item.AsString(opts.Ansi))
}
if count > 0 {
- os.Exit(exitOk)
+ util.Exit(exitOk)
}
- os.Exit(exitNoMatch)
+ util.Exit(exitNoMatch)
}
determine(val.final)
}