Skip to content

Commit

Permalink
rc: install interrupt handler earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
zimbatm committed Apr 17, 2022
1 parent 4b5e06e commit 9e93381
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions internal/cmd/rc.go
Expand Up @@ -151,6 +151,15 @@ func (rc *RC) Load(previousEnv Env) (newEnv Env, err error) {
return
}

// Allow RC loads to be canceled with SIGINT
ctx, cancel := context.WithCancel(context.Background())
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
go func() {
<-c
cancel()
}()

// check what type of RC we're processing
// use different exec method for each
fn := "source_env"
Expand All @@ -171,15 +180,6 @@ func (rc *RC) Load(previousEnv Env) (newEnv Env, err error) {
rc.Path(),
)

// Allow RC loads to be canceled with SIGINT
ctx, cancel := context.WithCancel(context.Background())
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
go func() {
<-c
cancel()
}()

// G204: Subprocess launched with function call as argument or cmd arguments
// #nosec
cmd := exec.CommandContext(ctx, config.BashPath, "--noprofile", "--norc", "-c", arg)
Expand Down

0 comments on commit 9e93381

Please sign in to comment.