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

fix: ctrl+c problem in cli mode. #286

Closed
wants to merge 3 commits into from
Closed

fix: ctrl+c problem in cli mode. #286

wants to merge 3 commits into from

Conversation

leauny
Copy link
Contributor

@leauny leauny commented Oct 11, 2023

What problem were solved in this pull request?

Issue Number: close #281

Problem: 在cli模式使用ctrl+c后始终显示miniob > 无法退出。

What is changed and how it works?

问题原因

cli模式下signal_handler可以正常接收signal并关闭服务。
但由于信号处理完成后返回中断点继续执行,导致重新回到read_command函数无限循环直到获取到非空命令。

解决方法

移除read_command函数,如果命令为空,返回状态EMPTY_CMD
server.cpp调用处判断如果出现空命令,则重新执行read_event
这样可以利用到Server中的started_来判断服务是否已经关停,再按回车就会退出。

Other information

ctrl+c后必须再按回车才会结束readline的阻塞状态,然后才会退出。
这会导致接收到信号并且系统执行shutdown后可以再执行一条语句。(本pr未解决,不知道是否需要处理这种情况)

@hnwyllmm hnwyllmm self-assigned this Oct 12, 2023
@hnwyllmm
Copy link
Collaborator

我昨天试了一下是没办法一次性退出,我想再多看看相关的内容,不过这几天时间很少,我后面会持续关注这个问题。

@leauny leauny closed this Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use Ctrl+C to exit observer in cli mode
2 participants