Skip to content

Instantly share code, notes, and snippets.

@MasterDuke17
Created June 26, 2021 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MasterDuke17/1cc0dc0a6d78409a549e49b8570661f4 to your computer and use it in GitHub Desktop.
Save MasterDuke17/1cc0dc0a6d78409a549e49b8570661f4 to your computer and use it in GitHub Desktop.
diff --git tools/templates/moar/rakudo-m-build.c.in tools/templates/moar/rakudo-m-build.c.in
index 1c8df46ca..1b4280919 100644
--- tools/templates/moar/rakudo-m-build.c.in
+++ tools/templates/moar/rakudo-m-build.c.in
@@ -3,6 +3,7 @@
#include <string.h>
#include <errno.h>
#include <unistd.h>
+#include <sys/wait.h>
extern char **environ;
int main(int argc, char *argv[])
@@ -42,7 +43,16 @@ int main(int argc, char *argv[])
// parent folder.
setenv("RAKUDO_HOME", "@c_escape(@nfp(@base_dir@/gen/build_rakudo_home)@)@", 1);
- execve(moar, exec_argv, environ);
+ for (int i = 0; i < 100; i++) {
+ int pid = fork();
+ if (pid == 0) {
+ execve(moar, exec_argv, environ);
+ return 0;
+ }
+ int status;
+ wait(&status);
+ }
+
// execv doesn't return on successful exec.
fprintf(stderr, "ERROR: Failed to execute moar. Error code: %i\n", errno);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment