@@ -516,7 +516,7 @@ static int hyper_setup_container(struct hyper_pod *pod)
516516 fprintf (stdout , "pod init pid %d\n" , pod -> init_pid );
517517
518518 /* Wait for container start */
519- if (hyper_get_type_block (arg .ctl_pipe [0 ], & type ) < 0 ) {
519+ if (hyper_get_type (arg .ctl_pipe [0 ], & type ) < 0 ) {
520520 perror ("get container init ready message failed" );
521521 goto out ;
522522 }
@@ -669,6 +669,18 @@ static void hyper_print_uptime(void)
669669 close (fd );
670670}
671671
672+ static int hyper_destroy_pod (struct hyper_pod * pod )
673+ {
674+ if (pod -> init_pid == 0 ) {
675+ /* Pod stopped, just shutdown */
676+ hyper_shutdown ();
677+ } else {
678+ /* Kill pod */
679+ hyper_term_all (pod );
680+ }
681+ return 0 ;
682+ }
683+
672684static int hyper_start_pod (char * json , int length )
673685{
674686 struct hyper_pod * pod = & global_pod ;
@@ -684,7 +696,7 @@ static int hyper_start_pod(char *json, int length)
684696 }
685697
686698 if (hyper_setup_pod (pod ) < 0 ) {
687- hyper_shutdown (pod );
699+ hyper_destroy_pod (pod );
688700 return -1 ;
689701 }
690702
@@ -1151,7 +1163,7 @@ static int hyper_channel_handle(struct hyper_event *de, uint32_t len)
11511163 //break;
11521164 case DESTROYPOD :
11531165 fprintf (stdout , "get DESTROYPOD message\n" );
1154- hyper_shutdown (pod );
1166+ hyper_destroy_pod (pod );
11551167 return 0 ;
11561168 case EXECCMD :
11571169 ret = hyper_exec_cmd ((char * )buf -> data + 8 , len - 8 );
@@ -1183,9 +1195,9 @@ static int hyper_channel_handle(struct hyper_event *de, uint32_t len)
11831195 }
11841196
11851197 if (ret < 0 )
1186- hyper_send_type (de -> fd , ERROR );
1198+ hyper_send_msg_block (de -> fd , ERROR , 0 , NULL );
11871199 else
1188- hyper_send_msg (de -> fd , ACK , datalen , data );
1200+ hyper_send_msg_block (de -> fd , ACK , datalen , data );
11891201
11901202 free (data );
11911203 return 0 ;
0 commit comments