1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-17 21:10:39 +02:00

Redirect to log by redefining stdout and stderr

This commit is contained in:
Paul Cercueil 2013-12-06 00:22:02 +01:00
parent 7c1af3a03b
commit 6ef3f3b190

View File

@ -590,13 +590,22 @@ void LinkApp::launch(const string &selectedFile) {
string command = exec;
if (!params.empty()) command += " " + params;
if (gmenu2x->confInt["outputLogs"]
#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0)
if (gmenu2x->confInt["outputLogs"] && !consoleApp)
command += " &> " LOG_FILE;
#else
if (gmenu2x->confInt["outputLogs"])
command += " &> " LOG_FILE;
&& !consoleApp
#endif
) {
int fd = open(LOG_FILE, O_WRONLY | O_TRUNC | O_CREAT, 0644);
if (fd < 0) {
ERROR("Unable to open log file for write: %s\n", LOG_FILE);
} else {
fflush(stdout);
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
close(fd);
}
}
gmenu2x->saveSelection();