Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions libc/test/UnitTest/ExecuteFunctionUnix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int ProcessStatus::get_fatal_signal() {
ProcessStatus invoke_in_subprocess(FunctionCaller *func, unsigned timeout_ms) {
int pipe_fds[2];
if (::pipe(pipe_fds) == -1) {
::free(func);
delete func;
return ProcessStatus::error("pipe(2) failed");
}

Expand All @@ -46,13 +46,13 @@ ProcessStatus invoke_in_subprocess(FunctionCaller *func, unsigned timeout_ms) {
::fflush(stdout);
pid_t pid = ::fork();
if (pid == -1) {
::free(func);
delete func;
return ProcessStatus::error("fork(2) failed");
}

if (!pid) {
(*func)();
::free(func);
delete func;
::exit(0);
}
::close(pipe_fds[1]);
Expand All @@ -63,13 +63,13 @@ ProcessStatus invoke_in_subprocess(FunctionCaller *func, unsigned timeout_ms) {
// No events requested so this call will only return after the timeout or if
// the pipes peer was closed, signaling the process exited.
if (::poll(&poll_fd, 1, timeout_ms) == -1) {
::free(func);
delete func;
return ProcessStatus::error("poll(2) failed");
}
// If the pipe wasn't closed by the child yet then timeout has expired.
if (!(poll_fd.revents & POLLHUP)) {
::kill(pid, SIGKILL);
::free(func);
delete func;
return ProcessStatus::timed_out_ps();
}

Expand All @@ -78,11 +78,11 @@ ProcessStatus invoke_in_subprocess(FunctionCaller *func, unsigned timeout_ms) {
// and doesn't turn into a zombie.
pid_t status = ::waitpid(pid, &wstatus, 0);
if (status == -1) {
::free(func);
delete func;
return ProcessStatus::error("waitpid(2) failed");
}
assert(status == pid);
::free(func);
delete func;
return {wstatus};
}

Expand Down
2 changes: 1 addition & 1 deletion libc/test/UnitTest/FPExceptMatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ FPExceptMatcher::FPExceptMatcher(FunctionCaller *func) {
fputil::get_env(&oldEnv);
if (sigsetjmp(jumpBuffer, 1) == 0)
func->call();
free(func);
delete func;
// We restore the previous floating point environment after
// the call to the function which can potentially raise SIGFPE.
fputil::set_env(&oldEnv);
Expand Down
Loading