Cannot execvp a Carbon application
Here is a little test program to demonstrate a problem I am facing at the moment. I have an application (that I cannot change) that is calling out to execvp to execute an external program. Now I want to replace this external program by a Carbon application. Unfortunately for some reason the Carbon runtime cannot find the nib file (kIBCarbonRuntimeCantFindNibFile) It only succeeds if the this little test wrapper is inside the bundle and very next to the myapp executable.
#include "stdio.h"
int main(int argc, char** argv) {
char* exe = "carbon/build/Release/myapp.app/Contents/MacOS/myapp";
char* args[] = { "", NULL };
printf("executing [%s]\n", exe);
execvp (exe, args);
printf("done\\n");
}
As execvp replaces the original program I just assume the nib will get searched based on the path of the wrapper – not the program that is getting called by execvp. Which I still think is weird, but anyway. If someone has further details, could confirm or explain …maybe even has a smart way around this – please let me know!!
UPDATE:
the above test program has a bug and “unfortunately” works and does not reproduce the error. Now that is even worse :-( …but just for the record it should have
been.
#include "stdio.h"
int main(int argc, char** argv) {
char* exe = "carbon/build/Release/myapp.app/Contents/MacOS/myapp";
char* args[] = { exe, NULL };
printf("executing [%s]\n", exe);
execvp (args[0], args);
printf("done\\n");
}
Reading the man page in detail sometimes *does* help.