Skip to content

Commit 556b7b3

Browse files
committed
remove detatch
1 parent e6d865f commit 556b7b3

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

src/killer.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@ void *timeout_killer(void *timeout_killer_args) {
1111
// this is a new thread, kill the process if timeout
1212
pid_t pid = ((struct timeout_killer_args *)timeout_killer_args)->pid;
1313
int timeout = ((struct timeout_killer_args *)timeout_killer_args)->timeout;
14-
// On success, pthread_detach() returns 0; on error, it returns an error
15-
// number.
16-
if (pthread_detach(pthread_self()) != 0) {
17-
kill_pid(pid);
18-
return NULL;
19-
}
14+
2015
// usleep can't be used, for time args must < 1000ms
2116
// this may sleep longer that expected, but we will have a check at the end
2217
if (sleep((unsigned int)((timeout + 1000) / 1000)) != 0) {

src/runner.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,12 @@ void run(struct config *_config, struct result *_result) {
115115

116116
// process exited, we may need to cancel timeout killer thread
117117
if (_config->max_real_time != UNLIMITED) {
118-
if (_result->real_time < _config->max_real_time) {
119-
if (pthread_cancel(tid) != 0) {
120-
// todo logging
121-
};
122-
}
118+
if (pthread_cancel(tid) != 0) {
119+
// todo logging
120+
};
121+
if (pthread_join(tid, NULL) != 0) {
122+
// todo logging
123+
};
123124
}
124125

125126
if (WIFSIGNALED(status) != 0) {

0 commit comments

Comments
 (0)