dovecot-2.0: Added execv_const() and execvp_const() helper funct...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Mar 27 01:34:38 EET 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/ddbc6e8b2776
changeset: 10995:ddbc6e8b2776
user: Timo Sirainen <tss at iki.fi>
date: Sat Mar 27 01:33:33 2010 +0200
description:
Added execv_const() and execvp_const() helper functions.
diffstat:
src/lib/Makefile.am | 2 ++
src/lib/execv-const.c | 20 ++++++++++++++++++++
src/lib/execv-const.h | 9 +++++++++
3 files changed, 31 insertions(+), 0 deletions(-)
diffs (56 lines):
diff -r c78fe7920deb -r ddbc6e8b2776 src/lib/Makefile.am
--- a/src/lib/Makefile.am Sat Mar 27 00:35:20 2010 +0200
+++ b/src/lib/Makefile.am Sat Mar 27 01:33:33 2010 +0200
@@ -24,6 +24,7 @@
data-stack.c \
eacces-error.c \
env-util.c \
+ execv-const.c \
failures.c \
fd-close-on-exec.c \
fd-set-nonblock.c \
@@ -131,6 +132,7 @@
data-stack.h \
eacces-error.h \
env-util.h \
+ execv-const.h \
failures.h \
fd-close-on-exec.h \
fd-set-nonblock.h \
diff -r c78fe7920deb -r ddbc6e8b2776 src/lib/execv-const.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lib/execv-const.c Sat Mar 27 01:33:33 2010 +0200
@@ -0,0 +1,20 @@
+/* Copyright (c) 2010 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "execv-const.h"
+
+#include <unistd.h>
+
+void execv_const(const char *path, const char *const argv[])
+{
+ (void)execv(path, (void *)argv);
+ i_fatal_status(errno == ENOMEM ? FATAL_OUTOFMEM : FATAL_EXEC,
+ "execv(%s) failed: %m", path);
+}
+
+void execvp_const(const char *file, const char *const argv[])
+{
+ (void)execvp(file, (void *)argv);
+ i_fatal_status(errno == ENOMEM ? FATAL_OUTOFMEM : FATAL_EXEC,
+ "execvp(%s) failed: %m", file);
+}
diff -r c78fe7920deb -r ddbc6e8b2776 src/lib/execv-const.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lib/execv-const.h Sat Mar 27 01:33:33 2010 +0200
@@ -0,0 +1,9 @@
+#ifndef EXECV_CONST_H
+#define EXECV_CONST_H
+
+/* Just like execv() and execvp(), except argv points to const strings.
+ Also if calling execv*() fails, these functions call i_fatal(). */
+void execv_const(const char *path, const char *const argv[]) ATTR_NORETURN;
+void execvp_const(const char *file, const char *const argv[]) ATTR_NORETURN;
+
+#endif
More information about the dovecot-cvs
mailing list