aboutsummaryrefslogtreecommitdiffstats
path: root/pseudo_wrappers.c
diff options
context:
space:
mode:
authorPeter Seebach <peter.seebach@windriver.com>2010-04-21 13:34:33 -0700
committerPeter Seebach <peter.seebach@windriver.com>2010-04-26 17:13:45 -0700
commitcc00abcd92f3d1c491d262266115dcee71b9a7a1 (patch)
tree164174c52ae1e22cd86dd4c4be06f35745cf3216 /pseudo_wrappers.c
parentf8410162d1bd5b61c05434669e20a160379488de (diff)
downloadpseudo-cc00abcd92f3d1c491d262266115dcee71b9a7a1.tar.gz
pseudo-cc00abcd92f3d1c491d262266115dcee71b9a7a1.tar.bz2
pseudo-cc00abcd92f3d1c491d262266115dcee71b9a7a1.zip
Allow specification of debug output file.
This includes allowing %s (program name) and %d (pid).
Diffstat (limited to 'pseudo_wrappers.c')
-rw-r--r--pseudo_wrappers.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/pseudo_wrappers.c b/pseudo_wrappers.c
index 2ea4a04..041a2f5 100644
--- a/pseudo_wrappers.c
+++ b/pseudo_wrappers.c
@@ -121,6 +121,7 @@ pseudo_populate_wrappers(void) {
char *debug;
static int done = 0;
char *pseudo_path = 0;
+ int fd;
if (done)
return done;
@@ -149,6 +150,29 @@ pseudo_populate_wrappers(void) {
pseudo_debug_verbose();
}
}
+ if (getenv("PSEUDO_DEBUG_FILE")) {
+ char filebuf[pseudo_path_max()], *fmt = getenv("PSEUDO_DEBUG_FILE");
+ char *name, *pid;
+ name = strstr(fmt, "%s");
+ pid = strstr(fmt, "%d");
+ if (name && pid) {
+ if (name > pid) {
+ snprintf(filebuf, pseudo_path_max(), fmt, getpid(), program_invocation_short_name);
+ } else {
+ snprintf(filebuf, pseudo_path_max(), fmt, program_invocation_short_name, getpid());
+ }
+ } else if (name) {
+ snprintf(filebuf, pseudo_path_max(), fmt, program_invocation_short_name);
+ } else if (pid) {
+ snprintf(filebuf, pseudo_path_max(), fmt, getpid());
+ } else {
+ snprintf(filebuf, pseudo_path_max(), "%s", fmt);
+ }
+ fd = open(filebuf, O_WRONLY | O_APPEND | O_CREAT, 0644);
+ if (fd >= 0) {
+ pseudo_util_debug_fd = fd;
+ }
+ }
/* must happen after wrappers are set up, because it can call
* getcwd(), which needs wrappers, but must happen here so that
* any attempt to use a path in a wrapper function will have a