From: Mark Wong Date: Tue, 26 Aug 2008 05:25:20 +0000 (-0700) Subject: Stop changing the working directory because it seems to confuse PostgreSQL. X-Git-Tag: v0.0.5~26 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=3e69eb49ec6ae9882fa315a6cafb44f4ed4eae6f;p=pg_proctab.git Stop changing the working directory because it seems to confuse PostgreSQL. --- diff --git a/pg_cputime.c b/pg_cputime.c index 4adb100..45a6ec1 100644 --- a/pg_cputime.c +++ b/pg_cputime.c @@ -117,13 +117,11 @@ Datum pg_cputime(PG_FUNCTION_ARGS) char **values = NULL; - chdir(PROCFS); - /* * Sanity check, make sure we read the pid information that we're * asking for. */ - sprintf(buffer, "stat"); + sprintf(buffer, "%s/stat", PROCFS); fd = open(buffer, O_RDONLY); if (fd == -1) { diff --git a/pg_loadavg.c b/pg_loadavg.c index bad1ebe..ec5d4c2 100644 --- a/pg_loadavg.c +++ b/pg_loadavg.c @@ -117,13 +117,11 @@ Datum pg_loadavg(PG_FUNCTION_ARGS) char **values = NULL; - chdir(PROCFS); - /* * Sanity check, make sure we read the pid information that we're * asking for. */ - sprintf(buffer, "loadavg"); + sprintf(buffer, "%s/loadavg", PROCFS); fd = open(buffer, O_RDONLY); if (fd == -1) { diff --git a/pg_memusage.c b/pg_memusage.c index 43d0a8e..ecde4e3 100644 --- a/pg_memusage.c +++ b/pg_memusage.c @@ -122,13 +122,11 @@ Datum pg_memusage(PG_FUNCTION_ARGS) char **values = NULL; - chdir(PROCFS); - /* * Sanity check, make sure we read the pid information that we're * asking for. */ - sprintf(buffer, "meminfo"); + sprintf(buffer, "%s/meminfo", PROCFS); fd = open(buffer, O_RDONLY); if (fd == -1) { diff --git a/pg_proctab.c b/pg_proctab.c index c9bad71..36bc7b2 100644 --- a/pg_proctab.c +++ b/pg_proctab.c @@ -193,7 +193,6 @@ Datum pg_proctab(PG_FUNCTION_ARGS) elog(ERROR, "proc filesystem not mounted on " PROCFS "\n"); SRF_RETURN_DONE(funcctx); } - chdir(PROCFS); /* Read the stat info for the pid. */ @@ -206,7 +205,7 @@ Datum pg_proctab(PG_FUNCTION_ARGS) * Sanity check, make sure we read the pid information that we're * asking for. */ - sprintf(buffer, "%d/stat", pid); + sprintf(buffer, "%s/%d/stat", PROCFS, pid); fd = open(buffer, O_RDONLY); if (fd == -1) {