@@ -37,7 +37,7 @@ int ProcessStatus::get_fatal_signal() {
37
37
ProcessStatus invoke_in_subprocess (FunctionCaller *func, unsigned timeout_ms) {
38
38
int pipe_fds[2 ];
39
39
if (::pipe (pipe_fds) == -1 ) {
40
- ::free ( func) ;
40
+ delete func;
41
41
return ProcessStatus::error (" pipe(2) failed" );
42
42
}
43
43
@@ -46,13 +46,13 @@ ProcessStatus invoke_in_subprocess(FunctionCaller *func, unsigned timeout_ms) {
46
46
::fflush (stdout);
47
47
pid_t pid = ::fork ();
48
48
if (pid == -1 ) {
49
- ::free ( func) ;
49
+ delete func;
50
50
return ProcessStatus::error (" fork(2) failed" );
51
51
}
52
52
53
53
if (!pid) {
54
54
(*func)();
55
- ::free ( func) ;
55
+ delete func;
56
56
::exit (0 );
57
57
}
58
58
::close (pipe_fds[1 ]);
@@ -63,13 +63,13 @@ ProcessStatus invoke_in_subprocess(FunctionCaller *func, unsigned timeout_ms) {
63
63
// No events requested so this call will only return after the timeout or if
64
64
// the pipes peer was closed, signaling the process exited.
65
65
if (::poll (&poll_fd, 1 , timeout_ms) == -1 ) {
66
- ::free ( func) ;
66
+ delete func;
67
67
return ProcessStatus::error (" poll(2) failed" );
68
68
}
69
69
// If the pipe wasn't closed by the child yet then timeout has expired.
70
70
if (!(poll_fd.revents & POLLHUP)) {
71
71
::kill (pid, SIGKILL);
72
- ::free ( func) ;
72
+ delete func;
73
73
return ProcessStatus::timed_out_ps ();
74
74
}
75
75
@@ -78,11 +78,11 @@ ProcessStatus invoke_in_subprocess(FunctionCaller *func, unsigned timeout_ms) {
78
78
// and doesn't turn into a zombie.
79
79
pid_t status = ::waitpid (pid, &wstatus, 0 );
80
80
if (status == -1 ) {
81
- ::free ( func) ;
81
+ delete func;
82
82
return ProcessStatus::error (" waitpid(2) failed" );
83
83
}
84
84
assert (status == pid);
85
- ::free ( func) ;
85
+ delete func;
86
86
return {wstatus};
87
87
}
88
88
0 commit comments