提交 68547a5f 编写于 作者: jia zhang's avatar jia zhang

rune/libenclave: Fix runelet process to exit

If the program launched by rune exec is terminated, runelet process
is unstoppable. Just kick off it through the channel notifyExit.
Signed-off-by: NXiaozhe Wang <wangxiaozhe@linux.alibaba.com>
Signed-off-by: jia zhang's avatarJia Zhang <zhang.jia@linux.alibaba.com>
上级 4fc3c3c4
......@@ -125,11 +125,10 @@ func StartInitialization() (exitCode int32, err error) {
defer agentPipe.Close()
os.Unsetenv("_LIBENCLAVE_AGENTPIPE")
notifyExit := make(chan struct{})
notifySignal := make(chan os.Signal, signalBufferSize)
if fifoFd == -1 {
exitCode, err = remoteExec(agentPipe, config, notifySignal, notifyExit)
exitCode, err = remoteExec(agentPipe, config, notifySignal)
if err != nil {
return exitCode, err
}
......@@ -138,6 +137,7 @@ func StartInitialization() (exitCode int32, err error) {
return exitCode, err
}
notifyExit := make(chan struct{})
sigForwarderExit := forwardSignal(rt, notifySignal, notifyExit)
agentExit := startAgentService(agentPipe, notifyExit)
......@@ -230,7 +230,7 @@ func finalizeInitialization(fifoFd int) error {
return nil
}
func remoteExec(agentPipe *os.File, config *configs.InitEnclaveConfig, notifySignal chan os.Signal, notifyExit <-chan struct{}) (exitCode int32, err error) {
func remoteExec(agentPipe *os.File, config *configs.InitEnclaveConfig, notifySignal chan os.Signal) (exitCode int32, err error) {
logrus.Debugf("preparing to remote exec %s", strings.Join(config.Cmd, " "))
c, err := net.FileConn(agentPipe)
......@@ -289,6 +289,8 @@ func remoteExec(agentPipe *os.File, config *configs.InitEnclaveConfig, notifySig
childSignalPipe.Close()
signal.Notify(notifySignal)
notifyExit := make(chan struct{})
sigForwarderExit := forwardSignalToParent(parentSignalPipe, notifySignal, notifyExit)
resp := &pb.AgentServiceResponse{}
......@@ -296,6 +298,7 @@ func remoteExec(agentPipe *os.File, config *configs.InitEnclaveConfig, notifySig
return 1, err
}
notifyExit <- struct{}{}
logrus.Debug("awaiting for signal forwarder exiting ...")
<-sigForwarderExit
logrus.Debug("signal forwarder exited")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册