@@ -516,7 +516,7 @@ static int hyper_setup_container(struct hyper_pod *pod)
516
516
fprintf (stdout , "pod init pid %d\n" , pod -> init_pid );
517
517
518
518
/* 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 ) {
520
520
perror ("get container init ready message failed" );
521
521
goto out ;
522
522
}
@@ -669,6 +669,18 @@ static void hyper_print_uptime(void)
669
669
close (fd );
670
670
}
671
671
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
+
672
684
static int hyper_start_pod (char * json , int length )
673
685
{
674
686
struct hyper_pod * pod = & global_pod ;
@@ -684,7 +696,7 @@ static int hyper_start_pod(char *json, int length)
684
696
}
685
697
686
698
if (hyper_setup_pod (pod ) < 0 ) {
687
- hyper_shutdown (pod );
699
+ hyper_destroy_pod (pod );
688
700
return -1 ;
689
701
}
690
702
@@ -1151,7 +1163,7 @@ static int hyper_channel_handle(struct hyper_event *de, uint32_t len)
1151
1163
//break;
1152
1164
case DESTROYPOD :
1153
1165
fprintf (stdout , "get DESTROYPOD message\n" );
1154
- hyper_shutdown (pod );
1166
+ hyper_destroy_pod (pod );
1155
1167
return 0 ;
1156
1168
case EXECCMD :
1157
1169
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)
1183
1195
}
1184
1196
1185
1197
if (ret < 0 )
1186
- hyper_send_type (de -> fd , ERROR );
1198
+ hyper_send_msg_block (de -> fd , ERROR , 0 , NULL );
1187
1199
else
1188
- hyper_send_msg (de -> fd , ACK , datalen , data );
1200
+ hyper_send_msg_block (de -> fd , ACK , datalen , data );
1189
1201
1190
1202
free (data );
1191
1203
return 0 ;
0 commit comments