-
-
Save msporleder/62d5bbd5dda6dd23d81d83730e8c77de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
int main(int argc, char *argv[]) { | |
char *execn; | |
asprintf(&execn, "%s%s", "--execname=", argv[0]); | |
/* libpaths need to be generated at perl6 compile time */ | |
char *margs[] = { | |
execn, | |
"--libpath=/usr/pkg/share/nqp/lib", | |
"--libpath=/usr/pkg/share/perl6/lib", | |
"--libpath=/usr/pkg/share/perl6/runtime", | |
"/usr/pkg/share/perl6/runtime/perl6.moarvm", | |
}; | |
int i; | |
size_t argvsz = 0; | |
for (i = 0; i < argc; i++) { | |
argvsz += strlen(argv[i]); | |
} | |
char **margs2 = malloc(sizeof(margs) + argvsz + sizeof(*argv)); | |
size_t idx = sizeof(margs)/sizeof(*margs) - 1; | |
for (i = 0; i <= idx ; i++) { | |
margs2[i] = margs[i]; | |
} | |
for (i = 1; i < argc; i++) { | |
margs2[idx+i] = argv[i]; | |
} | |
execv("/usr/pkg/bin/moar", margs2); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment