@@ -402,13 +402,14 @@ static int hyper_container_stage0(void *data)
402
402
403
403
ret = hyper_start_container (c , utsns , ipcns , pod );
404
404
out :
405
+ close (pidns );
406
+ close (utsns );
407
+ close (ipcns );
408
+
405
409
if (hyper_send_type (arg -> ctl_pipe [1 ], ret ? ERROR : READY ) < 0 ) {
406
410
fprintf (stderr , "container init send ready message failed\n" );
407
411
}
408
412
409
- close (pidns );
410
- close (utsns );
411
- close (ipcns );
412
413
/* hyper_container_stage0 shares fd table with init, let init closes pipe. */
413
414
//close(arg->ctl_pipe[0]);
414
415
//close(arg->ctl_pipe[1]);
@@ -440,7 +441,6 @@ int hyper_start_container_stage0(struct hyper_container *c, struct hyper_pod *po
440
441
}
441
442
442
443
pid = clone (hyper_container_stage0 , stack + stacksize , CLONE_VM | CLONE_FILES | SIGCHLD , & arg );
443
- free (stack );
444
444
if (pid < 0 ) {
445
445
perror ("enter container pid ns failed" );
446
446
goto out ;
@@ -464,6 +464,8 @@ int hyper_start_container_stage0(struct hyper_container *c, struct hyper_pod *po
464
464
out :
465
465
close (arg .ctl_pipe [0 ]);
466
466
close (arg .ctl_pipe [1 ]);
467
+
468
+ free (stack );
467
469
return ret ;
468
470
}
469
471
@@ -916,7 +918,7 @@ static int hyper_do_cmd_read_file(void *data)
916
918
ret = 0 ;
917
919
err :
918
920
hyper_send_type (arg -> pipe [1 ], ret ? ERROR : READY );
919
- return ret ;
921
+ _exit ( ret ) ;
920
922
}
921
923
922
924
static 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_
967
969
}
968
970
969
971
pid = clone (hyper_do_cmd_read_file , stack + stacksize , CLONE_VM | SIGCHLD , & arg );
970
- free (stack );
971
972
if (pid < 0 ) {
972
973
perror ("fail to fork writter process" );
973
974
goto out ;
@@ -984,6 +985,7 @@ static int hyper_cmd_read_file(char *json, int length, uint32_t *datalen, uint8_
984
985
close (arg .pipe [1 ]);
985
986
free (reader .id );
986
987
free (reader .file );
988
+ free (stack );
987
989
988
990
return ret ;
989
991
}
0 commit comments