From 3e69eb49ec6ae9882fa315a6cafb44f4ed4eae6f Mon Sep 17 00:00:00 2001 From: Mark Wong Date: Mon, 25 Aug 2008 22:25:20 -0700 Subject: [PATCH] Stop changing the working directory because it seems to confuse PostgreSQL. --- pg_cputime.c | 4 +--- pg_loadavg.c | 4 +--- pg_memusage.c | 4 +--- pg_proctab.c | 3 +-- 4 files changed, 4 insertions(+), 11 deletions(-) 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) { -- 2.39.5