# HG changeset patch # User KUBOTA Yuji # Date 1405500238 -32400 # Node ID c80ffa6f37593b3f58b09e611b1e96640d200a74 # Parent db8eea95ac52867f9799418f0a1509a2b6e87424 Bug 1861: Improve the messaging about gathering stdout/stderr. reviewed-by: yasuenag diff -r db8eea95ac52 -r c80ffa6f3759 agent/ChangeLog --- a/agent/ChangeLog Fri Jun 20 12:10:55 2014 +0900 +++ b/agent/ChangeLog Wed Jul 16 17:43:58 2014 +0900 @@ -1,3 +1,7 @@ +2014-07-16 KUBOTA Yuji + + * Bug 1861: Improve the messaging about gathering stdout/stderr. + 2014-06-20 KUBOTA Yuji * Bug 1849: HeapStats agent should collect systemd-journald information diff -r db8eea95ac52 -r c80ffa6f3759 agent/src/fsUtil.cpp --- a/agent/src/fsUtil.cpp Fri Jun 20 12:10:55 2014 +0900 +++ b/agent/src/fsUtil.cpp Wed Jul 16 17:43:58 2014 +0900 @@ -207,6 +207,7 @@ if((st.st_mode & S_IFMT) != S_IFREG){ /* File isn't regular file. This route is not error. */ + PRINT_DEBUG_MSG_HEADER << "Couldn't copy file. Not a regular file: " << path << NEWLINE; return false; } diff -r db8eea95ac52 -r c80ffa6f3759 agent/src/logManager.cpp --- a/agent/src/logManager.cpp Fri Jun 20 12:10:55 2014 +0900 +++ b/agent/src/logManager.cpp Wed Jul 16 17:43:58 2014 +0900 @@ -1139,14 +1139,40 @@ } } - /* Copy stdout. */ - if (unlikely(!copyFile("/proc/self/fd/1", basePath, "fd1"))) { - PRINT_WARN_MSG("Failure copy standard output."); - } + /* Copy file descriptors, i.e. stdout and stderr, as avoid double work. */ + const int fdNum = 2; + const char streamList[fdNum][255] = { + /* Standard streams */ + "/proc/self/fd/1", "/proc/self/fd/2", + }; + + const char fdFile[fdNum][10] = {"fd1", "fd2"}; + char fdPath[fdNum][PATH_MAX]; + struct stat fdStat[fdNum]; + bool flagCopyStreams = true; + + for (int i=0; i