flush stdou before forking - removes multiple printfs in buffer still being

flushed


SVN revision: 29746
This commit is contained in:
Carsten Haitzler 2007-04-28 05:03:04 +00:00
parent dbdf7283cc
commit 38d5caf598
1 changed files with 15 additions and 16 deletions

View File

@ -264,16 +264,14 @@ precache(void)
int l, fd, children = 0, cret; int l, fd, children = 0, cret;
home = getenv("HOME"); home = getenv("HOME");
if (home) if (home) snprintf(buf, sizeof(buf), "%s/.e-precache", home);
snprintf(buf, sizeof(buf), "%s/.e-precache", home); else snprintf(buf, sizeof(buf), "/tmp/.e-precache");
else
snprintf(buf, sizeof(buf), "/tmp/.e-precache");
f = fopen(buf, "r"); f = fopen(buf, "r");
if (!f) return; if (!f) return;
unlink(buf); unlink(buf);
if (fork()) return; if (fork()) return;
while (fgets(buf, sizeof(buf), f)); // while (fgets(buf, sizeof(buf), f));
rewind(f); // rewind(f);
while (fgets(buf, sizeof(buf), f)) while (fgets(buf, sizeof(buf), f))
{ {
l = strlen(buf); l = strlen(buf);
@ -360,7 +358,8 @@ main(int argc, char **argv)
exit(0); exit(0);
} }
} }
while (do_precache) printf("E - PID=%i, do_precache=%i\n", getpid(), do_precache);
if (do_precache)
{ {
void *lib, *func; void *lib, *func;
@ -368,27 +367,27 @@ main(int argc, char **argv)
/* sanity checks - if precache might fail - check here first */ /* sanity checks - if precache might fail - check here first */
lib = dlopen("libevas.so", RTLD_GLOBAL | RTLD_LAZY); lib = dlopen("libevas.so", RTLD_GLOBAL | RTLD_LAZY);
if (!lib) dlopen("libevas.so.1", RTLD_GLOBAL | RTLD_LAZY); if (!lib) dlopen("libevas.so.1", RTLD_GLOBAL | RTLD_LAZY);
if (!lib) break; if (!lib) goto done;
func = dlsym(lib, "evas_init"); func = dlsym(lib, "evas_init");
if (!func) break; if (!func) goto done;
lib = dlopen("libecore_file.so", RTLD_GLOBAL | RTLD_LAZY); lib = dlopen("libecore_file.so", RTLD_GLOBAL | RTLD_LAZY);
if (!lib) dlopen("libecore_file.so.1", RTLD_GLOBAL | RTLD_LAZY); if (!lib) dlopen("libecore_file.so.1", RTLD_GLOBAL | RTLD_LAZY);
if (!lib) break; if (!lib) goto done;
func = dlsym(lib, "ecore_file_init"); func = dlsym(lib, "ecore_file_init");
if (!func) break; if (!func) goto done;
lib = dlopen("libeet.so", RTLD_GLOBAL | RTLD_LAZY); lib = dlopen("libeet.so", RTLD_GLOBAL | RTLD_LAZY);
if (!lib) dlopen("libeet.so.0", RTLD_GLOBAL | RTLD_LAZY); if (!lib) dlopen("libeet.so.0", RTLD_GLOBAL | RTLD_LAZY);
if (!lib) break; if (!lib) goto done;
func = dlsym(lib, "eet_init"); func = dlsym(lib, "eet_init");
if (!func) break; if (!func) goto done;
/* precache SHOULD work */ /* precache SHOULD work */
printf("E PRECACHE ENABLED\n");
snprintf(buf, sizeof(buf), "%s/lib/enlightenment/preload/e_precache.so", _prefix_path); snprintf(buf, sizeof(buf), "%s/lib/enlightenment/preload/e_precache.so", _prefix_path);
env_set("LD_PRELOAD", buf); env_set("LD_PRELOAD", buf);
printf("E - PRECACHE GOING NOW...\n");
fflush(stdout);
precache(); precache();
do_precache = 0;
break;
} }
done:
args = alloca((argc + 1) * sizeof(char *)); args = alloca((argc + 1) * sizeof(char *));
args[0] = "enlightenment"; args[0] = "enlightenment";