fix(exec): fix segfault on exec failure

This commit is contained in:
zawz 2022-01-28 09:38:42 +01:00
parent d41ec0e3c6
commit b2c5aeea02
2 changed files with 4 additions and 2 deletions

View file

@ -260,10 +260,10 @@ int exec_process(std::string const& runtime, std::vector<std::string> const& arg
}
catch(std::runtime_error& e)
{
fclose(ffd);
unlink(fifopath.c_str());
if(pid != 0)
kill(pid, SIGINT);
fclose(ffd);
unlink(fifopath.c_str());
throw e;
}

View file

@ -139,6 +139,8 @@ int main(int argc, char* argv[])
ctx = make_context(filecontents, file, parse_bash);
if(is_exec)
{
delete sh;
sh = nullptr;
args.erase(args.begin());
return exec_process(shebang.substr(2), args, ctx);
}