1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-06 12:03:50 +08:00

fix Mrs4s#794

fix unexpected ReadPassword behavior in linux
This commit is contained in:
Ink33 2021-04-05 18:01:25 +08:00
parent 144220a1da
commit a361366916
No known key found for this signature in database
GPG Key ID: 5D8B1D036EFB0D2E

View File

@ -192,6 +192,7 @@ func main() {
if len(byteKey) == 0 { if len(byteKey) == 0 {
log.Infof("密码加密已启用, 请输入Key对密码进行解密以继续: (Enter 提交)") log.Infof("密码加密已启用, 请输入Key对密码进行解密以继续: (Enter 提交)")
cancel := make(chan struct{}, 1) cancel := make(chan struct{}, 1)
state, _ := term.GetState(int(os.Stdin.Fd()))
go func() { go func() {
select { select {
case <-cancel: case <-cancel:
@ -199,6 +200,7 @@ func main() {
case <-time.After(time.Second * 45): case <-time.After(time.Second * 45):
log.Infof("解密key输入超时") log.Infof("解密key输入超时")
time.Sleep(3 * time.Second) time.Sleep(3 * time.Second)
_ = term.Restore(int(os.Stdin.Fd()), state)
os.Exit(0) os.Exit(0)
} }
}() }()