You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by kl...@apache.org on 2022/07/05 09:19:04 UTC

[incubator-devlake] branch main updated: fix: direct run use c and enter to cancel (#2412)

This is an automated email from the ASF dual-hosted git repository.

klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new 4b575a85 fix: direct run use c and enter to cancel (#2412)
4b575a85 is described below

commit 4b575a85ff9565004c2d0fc058e3a268a45513f5
Author: mappjzc <zh...@merico.dev>
AuthorDate: Tue Jul 5 17:18:59 2022 +0800

    fix: direct run use c and enter to cancel (#2412)
    
    remove ctrl+z to cancel
    add c and enter to cancel.
    
    Nddtfjiang <zh...@merico.dev>
---
 runner/directrun.go | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/runner/directrun.go b/runner/directrun.go
index 8c0802ef..4e0fa19a 100644
--- a/runner/directrun.go
+++ b/runner/directrun.go
@@ -19,9 +19,7 @@ package runner
 
 import (
 	"context"
-	"os"
-	"os/signal"
-	"syscall"
+	"fmt"
 
 	"github.com/apache/incubator-devlake/config"
 	"github.com/apache/incubator-devlake/logger"
@@ -76,25 +74,20 @@ func DirectRun(cmd *cobra.Command, args []string, pluginTask core.PluginTask, op
 	}
 
 	ctx, cancel := context.WithCancel(context.Background())
-	sigc := make(chan os.Signal, 1)
-	signal.Notify(sigc, syscall.SIGTSTP)
 	go func() {
-		<-sigc
-		cancel()
-	}()
+		var buf string
 
-	go func() {
-		buf := make([]byte, 1)
-		n, err := os.Stdin.Read(buf)
+		n, err := fmt.Scan(&buf)
 		if err != nil {
 			panic(err)
-		} else if n == 1 && buf[0] == 99 {
+		} else if n == 1 && buf == "c" {
 			cancel()
 		} else {
-			println("unknown key press, code: ", buf[0])
+			println("unknown key press, code: ", buf)
+			println("press `c` and enter to send cancel signal")
 		}
 	}()
-	println("press `c` to send cancel signal")
+	println("press `c` and enter to send cancel signal")
 
 	err = RunPluginSubTasks(
 		cfg,