@@ -402,13 +402,14 @@ static int hyper_container_stage0(void *data)
402402
403403 ret = hyper_start_container (c , utsns , ipcns , pod );
404404out :
405+ close (pidns );
406+ close (utsns );
407+ close (ipcns );
408+
405409 if (hyper_send_type (arg -> ctl_pipe [1 ], ret ? ERROR : READY ) < 0 ) {
406410 fprintf (stderr , "container init send ready message failed\n" );
407411 }
408412
409- close (pidns );
410- close (utsns );
411- close (ipcns );
412413 /* hyper_container_stage0 shares fd table with init, let init closes pipe. */
413414 //close(arg->ctl_pipe[0]);
414415 //close(arg->ctl_pipe[1]);
@@ -440,7 +441,6 @@ int hyper_start_container_stage0(struct hyper_container *c, struct hyper_pod *po
440441 }
441442
442443 pid = clone (hyper_container_stage0 , stack + stacksize , CLONE_VM | CLONE_FILES | SIGCHLD , & arg );
443- free (stack );
444444 if (pid < 0 ) {
445445 perror ("enter container pid ns failed" );
446446 goto out ;
@@ -464,6 +464,8 @@ int hyper_start_container_stage0(struct hyper_container *c, struct hyper_pod *po
464464out :
465465 close (arg .ctl_pipe [0 ]);
466466 close (arg .ctl_pipe [1 ]);
467+
468+ free (stack );
467469 return ret ;
468470}
469471
@@ -916,7 +918,7 @@ static int hyper_do_cmd_read_file(void *data)
916918 ret = 0 ;
917919err :
918920 hyper_send_type (arg -> pipe [1 ], ret ? ERROR : READY );
919- return ret ;
921+ _exit ( ret ) ;
920922}
921923
922924static int hyper_cmd_read_file (char * json , int length , uint32_t * datalen , uint8_t * * data )
@@ -967,7 +969,6 @@ static int hyper_cmd_read_file(char *json, int length, uint32_t *datalen, uint8_
967969 }
968970
969971 pid = clone (hyper_do_cmd_read_file , stack + stacksize , CLONE_VM | SIGCHLD , & arg );
970- free (stack );
971972 if (pid < 0 ) {
972973 perror ("fail to fork writter process" );
973974 goto out ;
@@ -984,6 +985,7 @@ static int hyper_cmd_read_file(char *json, int length, uint32_t *datalen, uint8_
984985 close (arg .pipe [1 ]);
985986 free (reader .id );
986987 free (reader .file );
988+ free (stack );
987989
988990 return ret ;
989991}
0 commit comments