Fix execve(2) keeping program descriptors open.

This commit is contained in:
Jonas 'Sortie' Termansen 2015-07-09 18:32:30 +02:00
parent 4df23d9a36
commit fffefeba8f
1 changed files with 3 additions and 0 deletions

View File

@ -1169,6 +1169,7 @@ int sys_execve_kernel(const char* filename,
Ref<Descriptor> desc = from->open(&ctx, filename, O_EXEC | O_READ, 0); Ref<Descriptor> desc = from->open(&ctx, filename, O_EXEC | O_READ, 0);
if ( !desc ) if ( !desc )
return -1; return -1;
from.Reset();
struct stat st; struct stat st;
if ( desc->stat(&ctx, &st) ) if ( desc->stat(&ctx, &st) )
@ -1195,6 +1196,8 @@ int sys_execve_kernel(const char* filename,
sofar += amount; sofar += amount;
} }
desc.Reset();
int result = process->Execute(filename, buffer, filesize, argc, argv, envc, envp, regs); int result = process->Execute(filename, buffer, filesize, argc, argv, envc, envp, regs);
if ( result == 0 || errno != ENOEXEC || if ( result == 0 || errno != ENOEXEC ||