mirror of https://github.com/BOINC/boinc.git
Tweaks to screensaver
svn path=/trunk/boinc/; revision=13838
This commit is contained in:
parent
c4d01fe471
commit
a1da761346
|
@ -57,17 +57,6 @@ int main(int argc, char** argv) {
|
|||
strlcpy(user_name, "boinc_project", sizeof(user_name));
|
||||
strlcpy(group_name, "boinc_project", sizeof(group_name));
|
||||
|
||||
#if 0 // For debugging only
|
||||
char current_dir[MAXPATHLEN];
|
||||
|
||||
getcwd( current_dir, sizeof(current_dir));
|
||||
print_to_log_file( "current directory = %s", current_dir);
|
||||
|
||||
for (int i=0; i<argc; i++) {
|
||||
print_to_log_file("switcher arg %d: %s\n", i, argv[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0 // For debugging only
|
||||
// Allow debugging without running as user or group boinc_project
|
||||
pw = getpwuid(getuid());
|
||||
|
@ -87,6 +76,18 @@ int main(int argc, char** argv) {
|
|||
pw = getpwnam(user_name);
|
||||
if (pw) setuid(pw->pw_uid);
|
||||
|
||||
// NOTE: call print_to_log_file only after switching user and group
|
||||
#if 0 // For debugging only
|
||||
char current_dir[MAXPATHLEN];
|
||||
|
||||
getcwd( current_dir, sizeof(current_dir));
|
||||
print_to_log_file( "current directory = %s", current_dir);
|
||||
|
||||
for (int i=0; i<argc; i++) {
|
||||
print_to_log_file("switcher arg %d: %s\n", i, argv[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc < 2) return EINVAL;
|
||||
|
||||
if (strcmp(argv[1], "-launch_gfx") == 0) {
|
||||
|
@ -131,9 +132,8 @@ static void print_to_log_file(const char *format, ...) {
|
|||
va_list args;
|
||||
char buf[256];
|
||||
time_t t;
|
||||
strcpy(buf, getenv("HOME"));
|
||||
strcat(buf, "/Documents/test_log.txt");
|
||||
f = fopen(buf, "a");
|
||||
|
||||
f = fopen("/Users/Shared/test_log.txt", "a");
|
||||
if (!f) return;
|
||||
|
||||
// freopen(buf, "a", stdout);
|
||||
|
|
|
@ -245,7 +245,8 @@ int CScreensaver::terminate_screensaver(int& graphics_application, RESULT *worke
|
|||
int retval = 0;
|
||||
char current_dir[MAXPATHLEN];
|
||||
char gfx_pid[16];
|
||||
pid_t dont_care;
|
||||
pid_t thePID;
|
||||
int i;
|
||||
|
||||
sprintf(gfx_pid, "%d", graphics_application);
|
||||
getcwd( current_dir, sizeof(current_dir));
|
||||
|
@ -262,8 +263,15 @@ int CScreensaver::terminate_screensaver(int& graphics_application, RESULT *worke
|
|||
3,
|
||||
argv,
|
||||
0,
|
||||
dont_care
|
||||
thePID
|
||||
);
|
||||
if (retval) return retval;
|
||||
|
||||
for (i=0; i<200; i++) {
|
||||
boinc_sleep(0.01); // Wait 2 seconds max
|
||||
// Prevent gfx_switcher from becoming a zombie
|
||||
if (waitpid(thePID, 0, WNOHANG) == thePID) break;
|
||||
}
|
||||
return retval;
|
||||
#endif
|
||||
graphics_application = 0;
|
||||
|
|
Loading…
Reference in New Issue