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

use Ctrl+C to exit observer in cli mode #281

Closed
hnwyllmm opened this issue Oct 7, 2023 · 0 comments · Fixed by #328
Closed

use Ctrl+C to exit observer in cli mode #281

hnwyllmm opened this issue Oct 7, 2023 · 0 comments · Fixed by #328
Labels
enhancement New feature or request help wanted Needs help from a contributor

Comments

@hnwyllmm
Copy link
Collaborator

hnwyllmm commented Oct 7, 2023

Enhancement
If start observer in cli mode, we cannot exit observer by Ctrl+C.

@hnwyllmm hnwyllmm added enhancement New feature or request help wanted Needs help from a contributor labels Oct 7, 2023
Helloworld-lbl added a commit to Helloworld-lbl/miniob_main that referenced this issue Dec 4, 2023
    ### What problem were solved in this pull request?

    Issue Number: close oceanbase#281

    Problem: If start observer in cli mode, we cannot exit observer by Ctrl+C.

    ### What is changed and how it works?

    在待输入命令时按下Ctrl+C后,注意到日志中有这样的记录:
    "[2023-12-04 11:20:30.830780 pid:5338 tid:7fcf688ee7c0 ctx:0 WARN: my_readline@cli_communicator.cpp:71] >> failed to read line: Interrupted system call"
    结合“cli_communicator.cpp:71”代码,可以知道此时系统错误被捕捉到且记录在errno中(此时errno为4)。
    故当fgets读到空字符串时,若errno==4,可判定此时用户按下了Ctrl+C,这与用户输入“exit”等退出命令是等效的,故可看为用户输入了“interrupted",借用“bool is_exit_command(const char *cmd)”函数判断用户输入的命令是否是退出命令,即可实现类似于用户输入了“exit”等命令的退出效果。

    ### Other information
Helloworld-lbl added a commit to Helloworld-lbl/miniob_main that referenced this issue Dec 4, 2023
    ### What problem were solved in this pull request?

    Issue Number: close oceanbase#281

    Problem: If start observer in cli mode, we cannot exit observer by Ctrl+C.

    ### What is changed and how it works?

    在待输入命令时按下Ctrl+C后,注意到日志中有这样的记录:
    "[2023-12-04 11:20:30.830780 pid:5338 tid:7fcf688ee7c0 ctx:0 WARN: my_readline@cli_communicator.cpp:71] >> failed to read line: Interrupted system call"
    结合“cli_communicator.cpp:71”代码,可以知道此时系统错误被捕捉到且记录在errno中(此时errno为4)。
    故当fgets读到空字符串时,若errno==4,可判定此时用户按下了Ctrl+C,这与用户输入“exit”等退出命令是等效的,故可看为用户输入了“interrupted",借用“bool is_exit_command(const char *cmd)”函数判断用户输入的命令是否是退出命令,即可实现类似于用户输入了“exit”等命令的退出效果。

    ### Other information
hnwyllmm pushed a commit that referenced this issue Dec 4, 2023
### What problem were solved in this pull request?

Issue Number: close #281

Problem: If start observer in cli mode, we cannot exit observer by
Ctrl+C.

### What is changed and how it works?

    在待输入命令时按下Ctrl+C后,注意到日志中有这样的记录:
"[2023-12-04 11:20:30.830780 pid:5338 tid:7fcf688ee7c0 ctx:0 WARN:
my_readline@cli_communicator.cpp:71] >> failed to read line: Interrupted
system call"
    结合“cli_communicator.cpp:71”代码,可以知道此时系统错误被捕捉到且记录在errno中(此时errno为4)。

故当fgets读到空字符串时,若errno==4,可判定此时用户按下了Ctrl+C,这与用户输入“exit”等退出命令是等效的,故可看为用户输入了“interrupted",借用“bool
is_exit_command(const char
*cmd)”函数判断用户输入的命令是否是退出命令,即可实现类似于用户输入了“exit”等命令的退出效果。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Needs help from a contributor
Projects
None yet
1 participant