summaryrefslogtreecommitdiff
path: root/src/config.h
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-02-26 11:52:12 +0100
committerantirez <antirez@gmail.com>2013-02-26 11:52:12 +0100
commit6356cf6808be9ea88ab97be33ebf1576eeb57da6 (patch)
tree51bfa08218992715d44a61a2c4e2066c8c394606 /src/config.h
parent1b1b3f6c068eab655c5c5e84891fe1970f36c923 (diff)
downloadredis-6356cf6808be9ea88ab97be33ebf1576eeb57da6.tar.gz
Set process name in ps output to make operations safer.
This commit allows Redis to set a process name that includes the binding address and the port number in order to make operations simpler. Redis children processes doing AOF rewrites or RDB saving change the name into redis-aof-rewrite and redis-rdb-bgsave respectively. This in general makes harder to kill the wrong process because of an error and makes simpler to identify saving children. This feature was suggested by Arnaud GRANAL in the Redis Google Group, Arnaud also pointed me to the setproctitle.c implementation includeed in this commit. This feature should work on all the Linux, OSX, and all the three major BSD systems.
Diffstat (limited to 'src/config.h')
-rw-r--r--src/config.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/config.h b/src/config.h
index 68e99b427..961503c63 100644
--- a/src/config.h
+++ b/src/config.h
@@ -105,6 +105,18 @@
#define rdb_fsync_range(fd,off,size) fsync(fd)
#endif
+/* Check if we can use setproctitle().
+ * BSD systems have support for it, we provide an implementation for
+ * Linux and osx. */
+#if (defined __NetBSD__ || defined __FreeBSD__ || defined __OpenBSD__)
+#define USE_SETPROCTITLE
+#endif
+
+#if (defined __linux || defined __APPLE__)
+#define USE_SETPROCTITLE
+void setproctitle(const char *fmt, ...);
+#endif
+
/* Byte ordering detection */
#include <sys/types.h> /* This will likely define BYTE_ORDER */