summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2020-05-02 21:34:10 +0900
committerYusuke Endoh <mame@ruby-lang.org>2020-05-02 21:34:10 +0900
commit91e4e2403e950d06eb49840bdb11409321002847 (patch)
tree16ab8af0fc4c398dd7f9a27d056cd181d796c8a7 /internal
parentbb2ca762375d89a9c48abb14c4f79d68f2b49a5a (diff)
internal/process.h: add a no-warning simple wrapper for fork(2)
As fork(2) is deprecated, its calls must be guarded by `COMPILER_WARNING_IGNORED(-Wdeprecated-declarations)`. All usages of fork(2) in process have been alread guarded. A new call to fork(2) was added in ruby.c with f22c4ff359498ab342e4b6d6feb21af6004ee270. This caused a build failure on Solaris 11. It may hide a bug to guard big code unnecessarily, so this change introduces a simple wrapper "rb_fork" whose definition is guarded, and replaces all calls to fork(2) with the wrapper function.
Diffstat (limited to 'internal')
-rw-r--r--internal/process.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/process.h b/internal/process.h
index b47f857bb4..62d54d8b37 100644
--- a/internal/process.h
+++ b/internal/process.h
@@ -22,6 +22,7 @@
#include "ruby/ruby.h" /* for VALUE */
#include "internal/imemo.h" /* for RB_IMEMO_TMPBUF_PTR */
+#include "internal/warnings.h" /* for COMPILER_WARNING_PUSH */
#define RB_MAX_GROUPS (65536)
@@ -113,4 +114,15 @@ ARGVSTR2ARGC(VALUE argv_str)
return i - 1;
}
+COMPILER_WARNING_PUSH
+#if __has_warning("-Wdeprecated-declarations") || RUBY3_COMPILER_IS(GCC)
+COMPILER_WARNING_IGNORED(-Wdeprecated-declarations)
+#endif
+static inline rb_pid_t
+rb_fork(void)
+{
+ return fork();
+}
+COMPILER_WARNING_POP
+
#endif /* INTERNAL_PROCESS_H */