summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-04-03 00:02:03 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-04-03 00:02:03 +0000
commit9e5797086070017db226db2159737d2894714a5b (patch)
treeba3766d9cfbb1e65b6c1d05386dd544db0b47538
parent774cdb9159a9f9bbf0dcc3e22d43646c66db0759 (diff)
downloadpostgresql-9e5797086070017db226db2159737d2894714a5b.tar.gz
Put back code mistakenly removed from copy of postmaster's
daemonize routine, namely forcing stdin/stdout/stderr to point to /dev/null. Per Karl Denninger.
-rw-r--r--contrib/pg_autovacuum/pg_autovacuum.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/contrib/pg_autovacuum/pg_autovacuum.c b/contrib/pg_autovacuum/pg_autovacuum.c
index b3f5a4e371..dc8e73d414 100644
--- a/contrib/pg_autovacuum/pg_autovacuum.c
+++ b/contrib/pg_autovacuum/pg_autovacuum.c
@@ -4,7 +4,7 @@
* Revisions by Christopher B. Browne, Liberty RMS
* Win32 Service code added by Dave Page
*
- * $PostgreSQL: pgsql/contrib/pg_autovacuum/pg_autovacuum.c,v 1.27.4.2 2005/01/26 22:25:23 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pg_autovacuum/pg_autovacuum.c,v 1.27.4.3 2005/04/03 00:02:03 tgl Exp $
*/
#include "postgres_fe.h"
@@ -18,6 +18,8 @@
#ifdef WIN32
#include <windows.h>
#endif
+#include <sys/stat.h>
+#include <fcntl.h>
#include "pg_autovacuum.h"
@@ -186,13 +188,13 @@ log_entry(const char *logentry, int level)
* Function used to detach the pg_autovacuum daemon from the tty and go into
* the background.
*
- * This code is mostly ripped directly from pm_dameonize in postmaster.c with
- * unneeded code removed.
+ * This code is ripped directly from pmdaemonize in postmaster.c.
*/
#ifndef WIN32
static void
daemonize(void)
{
+ int i;
pid_t pid;
pid = fork();
@@ -209,7 +211,8 @@ daemonize(void)
}
/* GH: If there's no setsid(), we hopefully don't need silent mode.
- * Until there's a better solution. */
+ * Until there's a better solution.
+ */
#ifdef HAVE_SETSID
if (setsid() < 0)
{
@@ -218,7 +221,11 @@ daemonize(void)
_exit(1);
}
#endif
-
+ i = open(NULL_DEV, O_RDWR);
+ dup2(i, 0);
+ dup2(i, 1);
+ dup2(i, 2);
+ close(i);
}
#endif /* WIN32 */