X Tutup
Skip to content

Commit 8627739

Browse files
author
Liu Hua
committed
signal: do not print message when dealing with SIG_PIPE
If we print message when SIG_PIPE occuers in signal handler. There is a loop {print->SIG_PIPE->print->SIG_PIPE...}, which consume a lot of cpu time. So do not print message in this situaiton. Signed-off-by: Liu Hua <weldonliu@tencent.com>
1 parent 7c6d710 commit 8627739

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cmd/containerd/command/main_unix.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,17 @@ func handleSignals(ctx context.Context, signals chan os.Signal, serverC chan *se
4545
case s := <-serverC:
4646
server = s
4747
case s := <-signals:
48+
49+
// Do not print message when deailing with SIGPIPE, which may cause
50+
// nested signals and consume lots of cpu bandwidth.
51+
if s == unix.SIGPIPE {
52+
continue
53+
}
54+
4855
log.G(ctx).WithField("signal", s).Debug("received signal")
4956
switch s {
5057
case unix.SIGUSR1:
5158
dumpStacks(true)
52-
case unix.SIGPIPE:
53-
continue
5459
default:
5560
if err := notifyStopping(ctx); err != nil {
5661
log.G(ctx).WithError(err).Error("notify stopping failed")

0 commit comments

Comments
 (0)
X Tutup