Skip to content
Open
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
6 changes: 3 additions & 3 deletions R/frollapply.R
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,11 @@ frollapply = function(X, N, FUN, ..., by.column=TRUE, fill=NA, align=c("right","
interrupt = function(e) {
# nocov start
suspendInterrupts({
lapply(jobs, function(pid) try(tools::pskill(pid), silent = TRUE))
parallel::mccollect(jobs, wait = FALSE)
lapply(jobs[.Call(Cis_direct_child, jobs)], function(pid) try(tools::pskill(pid), silent = TRUE))
parallel::mccollect(jobs)
})
invokeRestart("abort") ## raise SIGINT
# nocov end
# Let the interrupt continue without invoking restarts
}
)
## check for any errors in FUN, warnings are silently ignored
Expand Down
1 change: 1 addition & 0 deletions src/data.table.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ SEXP R_allocResizableVector_(SEXPTYPE type, R_xlen_t maxlen);
SEXP R_duplicateAsResizable_(SEXP x);
void R_resizeVector_(SEXP x, R_xlen_t newlen);
#endif
SEXP is_direct_child(SEXP pids);

// types.c
char *end(char *start);
Expand Down
1 change: 1 addition & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ R_CallMethodDef callMethods[] = {
{"CmemcpyDTadaptive", (DL_FUNC)&memcpyDTadaptive, -1},
{"CcopyAsGrowable", (DL_FUNC)&copyAsGrowable, -1},
{"Cfrolladapt", (DL_FUNC)&frolladapt, -1},
{"Cis_direct_child", (DL_FUNC)&is_direct_child, -1},
{NULL, NULL, 0}
};

Expand Down
24 changes: 24 additions & 0 deletions src/utils.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifndef _WIN32
# include <sys/wait.h>
#endif

#include "data.table.h"

bool within_int32_repres(double x) {
Expand Down Expand Up @@ -684,3 +688,23 @@ void R_resizeVector_(SEXP x, R_xlen_t newlen) {
SETLENGTH(x, newlen);
}
#endif

// # nocov start
#ifdef _WIN32
NORET
#endif
SEXP is_direct_child(SEXP pids) {
#ifdef _WIN32
internal_error(__func__, "not implemented on Windows");
#else
int *ppids = INTEGER(pids);
R_xlen_t len = xlength(pids);
SEXP ret = allocVector(LGLSXP, len);
int *pret = LOGICAL(ret);
siginfo_t info;
for (R_xlen_t i = 0; i < len; ++i)
pret[i] = waitid(P_PID, ppids[i], &info, WCONTINUED | WEXITED | WNOHANG | WNOWAIT | WSTOPPED) == 0;
return ret;
#endif
}
// # nocov end
Loading