Skip to content

Commit

Permalink
webconsole: fix defer order to release zombie process
Browse files Browse the repository at this point in the history
  • Loading branch information
wanyaoqi committed Sep 14, 2020
1 parent 12aef33 commit 77c3e49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions pkg/webconsole/service/service.go
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/gorilla/mux"

"yunion.io/x/log"
"yunion.io/x/pkg/util/signalutils"

api "yunion.io/x/onecloud/pkg/apis/webconsole"
"yunion.io/x/onecloud/pkg/appsrv"
Expand Down Expand Up @@ -66,9 +67,15 @@ func StartService() {

common_options.StartOptionManager(opts, opts.ConfigSyncPeriodSeconds, api.SERVICE_TYPE, api.SERVICE_VERSION, o.OnOptionsChange)

registerSigTraps()
start()
}

func registerSigTraps() {
signalutils.SetDumpStackSignal()
signalutils.StartTrap()
}

func start() {
baseOpts := &o.Options.BaseOptions
// commonOpts := &o.Options.CommonOptions
Expand Down
7 changes: 4 additions & 3 deletions pkg/webconsole/session/pty_session.go
Expand Up @@ -102,6 +102,10 @@ func (p *Pty) Resize(size *pty.Winsize) {
func (p *Pty) Stop() (err error) {
var errs []error

defer func() {
p.Cmd, p.Pty = nil, nil
}()

defer func() {
err = errors.NewAggregate(errs)
}()
Expand Down Expand Up @@ -139,8 +143,5 @@ func (p *Pty) Stop() (err error) {
}
}()

defer func() {
p.Cmd, p.Pty = nil, nil
}()
return
}

0 comments on commit 77c3e49

Please sign in to comment.