diff --git a/R/frollapply.R b/R/frollapply.R index f8c5924e9..8396be93b 100644 --- a/R/frollapply.R +++ b/R/frollapply.R @@ -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 diff --git a/src/data.table.h b/src/data.table.h index ebfa1232c..e22608364 100644 --- a/src/data.table.h +++ b/src/data.table.h @@ -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); diff --git a/src/init.c b/src/init.c index ecdc64e39..e4e77e96c 100644 --- a/src/init.c +++ b/src/init.c @@ -160,6 +160,7 @@ R_CallMethodDef callMethods[] = { {"CmemcpyDTadaptive", (DL_FUNC)&memcpyDTadaptive, -1}, {"CcopyAsGrowable", (DL_FUNC)©AsGrowable, -1}, {"Cfrolladapt", (DL_FUNC)&frolladapt, -1}, +{"Cis_direct_child", (DL_FUNC)&is_direct_child, -1}, {NULL, NULL, 0} }; diff --git a/src/utils.c b/src/utils.c index a99e2cee3..8a051fadf 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,3 +1,7 @@ +#ifndef _WIN32 +# include +#endif + #include "data.table.h" bool within_int32_repres(double x) { @@ -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