Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

batches: handle interrupt signals in batch preview #793

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/src/batch_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"path/filepath"
"runtime"
"strings"
"syscall"
"time"

"github.com/mattn/go-isatty"
Expand Down Expand Up @@ -533,7 +534,7 @@ func checkExecutable(cmd string, args ...string) error {
func contextCancelOnInterrupt(parent context.Context) (context.Context, func()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe that name is not 100% accurate anymore.

ctx, ctxCancel := context.WithCancel(parent)
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)

go func() {
select {
Expand Down
4 changes: 2 additions & 2 deletions cmd/src/batch_preview.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"flag"
"fmt"

"github.com/sourcegraph/sourcegraph/lib/output"

"github.com/sourcegraph/src-cli/internal/batches/ui"
"github.com/sourcegraph/src-cli/internal/cmderrors"

"github.com/sourcegraph/sourcegraph/lib/output"
)

func init() {
Expand Down