You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/07/19 15:35:44 UTC

[GitHub] [arrow] pitrou commented on a diff in pull request #13635: ARROW-11841: [R][C++] Allow cancelling long-running commands

pitrou commented on code in PR #13635:
URL: https://github.com/apache/arrow/pull/13635#discussion_r924662599


##########
r/src/safe-call-into-r-impl.cpp:
##########
@@ -29,6 +37,58 @@ MainRThread& GetMainRThread() {
 // [[arrow::export]]
 void InitializeMainRThread() { GetMainRThread().Initialize(); }
 
+bool CanRunWithCapturedR() {
+#if defined(HAS_UNWIND_PROTECT)
+  static int on_old_windows = -1;
+  if (on_old_windows == -1) {
+    cpp11::function on_old_windows_fun = cpp11::package("arrow")["on_old_windows"];
+    on_old_windows = on_old_windows_fun();
+  }
+
+  return !on_old_windows;
+#else
+  return false;
+#endif
+}
+
+void SignalInterruptCondition() {
+#ifdef _WIN32
+  UserBreak = 1;
+  R_CheckUserInterrupt();
+#else
+  Rf_onintr();
+#endif
+}
+
+void OverridingSignalHandler(int sig) {
+  auto main_r_thread = GetMainRThread();

Review Comment:
   Is all this code really safe to execute from a signal handler (i.e. are all the APIs here reentrant)?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org