+int __stdout_stderr_redirection(int defpid)
+{
+ char defpath[UNIX_PATH_MAX];
+ int deffd, result=0;
+
+ /* stdout */
+ snprintf(defpath, UNIX_PATH_MAX, "/proc/%d/fd/1", defpid);
+ deffd = open(defpath,O_WRONLY);
+ if(deffd < 0) {
+ _E("opening caller(%d) stdout failed due to %s"
+ , defpid, strerror(errno));
+ result++;
+ }else{
+ dup2(deffd, 1);
+ close(deffd);
+ }
+
+ /* stderr */
+ snprintf(defpath, UNIX_PATH_MAX, "/proc/%d/fd/2", defpid);
+ deffd = open(defpath,O_WRONLY);
+ if(deffd < 0) {
+ _E("opening caller(%d) stderr failed due to %s"
+ , defpid,strerror(errno));
+ result+=2;
+ }else{
+ dup2(deffd, 2);
+ close(deffd);
+ }
+
+ return result;
+}
+