Commit 9f017f02

9f017f029affMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · ~3 modified

Description

runtime,codegen,test: Process.ppid -- MinGW lacks getppid

The Windows MinGW build of <unistd.h> doesn't expose getppid, so sp_process_ppid() wraps it with a #ifdef _WIN32 fallback returning 0. Also relax the test to assert ppid >= 0 (was > 0) so 0 is acceptable on Windows.

Fixes CI failure on the windows-mingw job introduced by the Process.pid/ppid commit.

Co-Authored-By: Claude Opus 4.7 [email protected]

Details

Commit
9f017f029aff
Parent
d1f96a3ec8ad

lib/sp_runtime.hmodifiedView file

@@ -442,6 +442,16 @@
442442 static const char sp_ruby_platform_data[] = "\xff" SP_RUBY_ARCH "-" SP_RUBY_OS;
443443 static inline const char *sp_ruby_platform_str(void) { return sp_ruby_platform_data + 1; }
444444
445+/* Process.ppid wrapper. MinGW's unistd.h doesn't expose getppid;
446+ return 0 there. Issue #893. */
447+static inline mrb_int sp_process_ppid(void) {
448+#ifdef _WIN32
449+ return 0;
450+#else
451+ return (mrb_int)getppid();
452+#endif
453+}
454+
445455 static void sp_oom_die(void);
446456 static char *sp_str_alloc(size_t len) {
447457 size_t total = sizeof(sp_str_hdr) + 1 + len + 1;