Bug 658840 - let glxtest process return from XRE_main rather than calling exit() - r=bsmedberg

Calling exit() resulted in two strings being considered leaked by valgrind. Returning from XRE_main() should fix that.
This commit is contained in:
Benoit Jacob 2011-06-10 15:07:54 -04:00
parent 90532908fc
commit d18185a968
2 changed files with 11 additions and 6 deletions

View File

@ -220,27 +220,31 @@ static void glxtest()
dlclose(libgl);
}
void fire_glxtest_process()
/** \returns true in the child glxtest process, false in the parent process */
bool fire_glxtest_process()
{
int pfd[2];
if (pipe(pfd) == -1) {
perror("pipe");
exit(EXIT_FAILURE);
return false;
}
pid_t pid = fork();
if (pid < 0) {
perror("fork");
exit(EXIT_FAILURE);
close(pfd[0]);
close(pfd[1]);
return false;
}
if (pid == 0) {
close(pfd[0]);
write_end_of_the_pipe = pfd[1];
glxtest();
close(pfd[1]);
exit(EXIT_SUCCESS);
return true;
}
close(pfd[1]);
mozilla::widget::glxtest_pipe = pfd[0];
mozilla::widget::glxtest_pid = pid;
return false;
}

View File

@ -2719,7 +2719,7 @@ PRTime gXRE_mainTimestamp = 0;
#ifdef MOZ_X11
#ifndef MOZ_PLATFORM_MAEMO
void fire_glxtest_process();
bool fire_glxtest_process();
#endif
#endif
@ -2749,7 +2749,8 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
// That's the whole reason for doing this in a separate process.
#ifdef MOZ_X11
#ifndef MOZ_PLATFORM_MAEMO
fire_glxtest_process();
if (fire_glxtest_process())
return 0;
#endif
#endif