vfs: pm_dumpcore: always clean up process
. whenever this function is called, pm will expect the process to be cleaned up . so don't abort the process entirely on error . fixes a later 'forking on top of in-use child' vfs panic
This commit is contained in:
parent
25817b0854
commit
60014efb3e
1 changed files with 6 additions and 5 deletions
|
@ -695,7 +695,7 @@ int do_svrctl()
|
|||
*===========================================================================*/
|
||||
int pm_dumpcore(endpoint_t proc_e, int csig, vir_bytes exe_name)
|
||||
{
|
||||
int slot, r, core_fd;
|
||||
int slot, r = OK, core_fd;
|
||||
struct filp *f;
|
||||
char core_path[PATH_MAX];
|
||||
char proc_name[PROC_NAME_LEN];
|
||||
|
@ -706,22 +706,23 @@ int pm_dumpcore(endpoint_t proc_e, int csig, vir_bytes exe_name)
|
|||
/* open core file */
|
||||
snprintf(core_path, PATH_MAX, "%s.%d", CORE_NAME, fp->fp_pid);
|
||||
core_fd = common_open(core_path, O_WRONLY | O_CREAT | O_TRUNC, CORE_MODE);
|
||||
if (core_fd < 0) return(core_fd);
|
||||
if (core_fd < 0) { r = core_fd; goto core_exit; }
|
||||
|
||||
/* get process' name */
|
||||
r = sys_datacopy(PM_PROC_NR, exe_name, VFS_PROC_NR, (vir_bytes) proc_name,
|
||||
PROC_NAME_LEN);
|
||||
if (r != OK) return(r);
|
||||
if (r != OK) goto core_exit;
|
||||
proc_name[PROC_NAME_LEN - 1] = '\0';
|
||||
|
||||
if ((f = get_filp(core_fd, VNODE_WRITE)) == NULL) return(EBADF);
|
||||
if ((f = get_filp(core_fd, VNODE_WRITE)) == NULL) { r=EBADF; goto core_exit; }
|
||||
write_elf_core_file(f, csig, proc_name);
|
||||
unlock_filp(f);
|
||||
(void) close_fd(fp, core_fd); /* ignore failure, we're exiting anyway */
|
||||
|
||||
core_exit:
|
||||
if(csig)
|
||||
free_proc(fp, FP_EXITING);
|
||||
return(OK);
|
||||
return(r);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
|
|
Loading…
Reference in a new issue