mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-12-26 20:02:30 +01:00
I don't know how it's possible, but checksum of fixes-for-process-status-in-ruby-3.patch doesn't match. It seems that commit patches on GitHub are really somehow unstable. :( Please note that I added the Patch-Source header to all downloaded patches, that's why they *all* have a different checksum.
97 lines
3.2 KiB
Diff
97 lines
3.2 KiB
Diff
Patch-Source: https://github.com/eventmachine/eventmachine/commit/daeb121fb5600cc0f4fc604fbf7d742578f26483.patch
|
|
--
|
|
From daeb121fb5600cc0f4fc604fbf7d742578f26483 Mon Sep 17 00:00:00 2001
|
|
From: MSP-Greg <Greg.mpls@gmail.com>
|
|
Date: Sat, 12 Jun 2021 22:37:37 -0500
|
|
Subject: [PATCH] Fixes for Process::Status changes in Ruby 3
|
|
|
|
---
|
|
ext/extconf.rb | 3 +++
|
|
ext/rubymain.cpp | 36 ++++++++++++++++++++++++++++++------
|
|
2 files changed, 33 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/ext/extconf.rb b/ext/extconf.rb
|
|
index 0fb654104..ce83c0028 100644
|
|
--- a/ext/extconf.rb
|
|
+++ b/ext/extconf.rb
|
|
@@ -138,6 +138,9 @@ def find_openssl_library
|
|
add_define "HAVE_KQUEUE" if have_header("sys/event.h") && have_header("sys/queue.h")
|
|
end
|
|
|
|
+# Add for changes to Process::Status in Ruby 3
|
|
+add_define("IS_RUBY_3_OR_LATER") if RUBY_VERSION > "3.0"
|
|
+
|
|
# Adjust number of file descriptors (FD) on Windows
|
|
|
|
if RbConfig::CONFIG["host_os"] =~ /mingw/
|
|
diff --git a/ext/rubymain.cpp b/ext/rubymain.cpp
|
|
index 5da5c8b25..36018c63d 100644
|
|
--- a/ext/rubymain.cpp
|
|
+++ b/ext/rubymain.cpp
|
|
@@ -85,7 +85,24 @@ static VALUE Intern_proxy_target_unbound;
|
|
static VALUE Intern_proxy_completed;
|
|
static VALUE Intern_connection_completed;
|
|
|
|
-static VALUE rb_cProcStatus;
|
|
+static VALUE rb_cProcessStatus;
|
|
+
|
|
+#ifdef IS_RUBY_3_OR_LATER
|
|
+struct rb_process_status {
|
|
+ rb_pid_t pid;
|
|
+ int status;
|
|
+ int error;
|
|
+};
|
|
+
|
|
+static const rb_data_type_t rb_process_status_type = {
|
|
+ .wrap_struct_name = "Process::Status",
|
|
+ .function = {
|
|
+ .dfree = RUBY_DEFAULT_FREE,
|
|
+ },
|
|
+ .data = NULL,
|
|
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
|
+};
|
|
+#endif
|
|
|
|
struct em_event {
|
|
uintptr_t signature;
|
|
@@ -553,11 +570,18 @@ static VALUE t_get_subprocess_status (VALUE self UNUSED, VALUE signature)
|
|
|
|
if (evma_get_subprocess_status (NUM2BSIG (signature), &status)) {
|
|
if (evma_get_subprocess_pid (NUM2BSIG (signature), &pid)) {
|
|
- proc_status = rb_obj_alloc(rb_cProcStatus);
|
|
|
|
+#ifdef IS_RUBY_3_OR_LATER
|
|
+ struct rb_process_status *data = NULL;
|
|
+ proc_status = TypedData_Make_Struct(rb_cProcessStatus, struct rb_process_status, &rb_process_status_type, data);
|
|
+ data->pid = pid;
|
|
+ data->status = status;
|
|
+#else
|
|
+ proc_status = rb_obj_alloc(rb_cProcessStatus);
|
|
/* MRI Ruby uses hidden instance vars */
|
|
- rb_iv_set(proc_status, "status", INT2FIX(status));
|
|
- rb_iv_set(proc_status, "pid", INT2FIX(pid));
|
|
+ rb_ivar_set(proc_status, rb_intern_const("status"), INT2FIX(status));
|
|
+ rb_ivar_set(proc_status, rb_intern_const("pid"), INT2FIX(pid));
|
|
+#endif
|
|
|
|
#ifdef RUBINIUS
|
|
/* Rubinius uses standard instance vars */
|
|
@@ -572,7 +596,7 @@ static VALUE t_get_subprocess_status (VALUE self UNUSED, VALUE signature)
|
|
#endif
|
|
}
|
|
}
|
|
-
|
|
+ rb_obj_freeze(proc_status);
|
|
return proc_status;
|
|
}
|
|
|
|
@@ -1431,7 +1455,7 @@ extern "C" void Init_rubyeventmachine()
|
|
{
|
|
// Lookup Process::Status for get_subprocess_status
|
|
VALUE rb_mProcess = rb_const_get(rb_cObject, rb_intern("Process"));
|
|
- rb_cProcStatus = rb_const_get(rb_mProcess, rb_intern("Status"));
|
|
+ rb_cProcessStatus = rb_const_get(rb_mProcess, rb_intern("Status"));
|
|
|
|
// Tuck away some symbol values so we don't have to look 'em up every time we need 'em.
|
|
Intern_at_signature = rb_intern ("@signature");
|