21 std::vector<char> argv(512, 0);
22 std::vector<char> parent(512, 0);
25 pid_t mypid = getpid();
26 memset(&buf, 0,
sizeof(buf));
27 buf.ps_pathlen = argv.size();
28 buf.ps_pathptr = &argv[0];
29 while ((token = w_getpsent(token, &buf,
sizeof(buf))) > 0) {
30 if (buf.ps_pid == mypid) {
37 if (__realpath_a(&argv[0], &parent[0]) == NULL)
44 std::vector<char> parent2(parent.begin(), parent.end());
48 std::ostringstream libpath;
49 libpath << getenv(
"LIBPATH");
50 libpath <<
":" << &parent[0] <<
"/lib.target/";
51 libpath <<
":" << &parent[0] <<
"/lib/";
52 libpath <<
":" << &parent2[0] <<
"/lib/";
53 setenv(
"LIBPATH", libpath.str().c_str(), 1);