mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-04 19:17:37 +08:00
deal with pipe close error
This commit is contained in:
parent
e2cafbd7d6
commit
752c82e8d6
@ -9,6 +9,7 @@ import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// SetupMainSignalHandler is for main to use at last
|
||||
func SetupMainSignalHandler() <-chan struct{} {
|
||||
mainOnce.Do(func() {
|
||||
mc := make(chan os.Signal, 2)
|
||||
|
@ -3,9 +3,12 @@
|
||||
package global
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
@ -20,6 +23,7 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
// SetupMainSignalHandler is for main to use at last
|
||||
func SetupMainSignalHandler() <-chan struct{} {
|
||||
mainOnce.Do(func() {
|
||||
// for stack trace collecting on windows
|
||||
@ -38,6 +42,9 @@ func SetupMainSignalHandler() <-chan struct{} {
|
||||
for {
|
||||
c, err := pipe.Accept()
|
||||
if err != nil {
|
||||
if errors.Is(err, net.ErrClosed) || strings.Contains(err.Error(), "closed") {
|
||||
return
|
||||
}
|
||||
log.Errorf("accept named pipe 失败: %v", err)
|
||||
continue
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user