lib: Add prctl_set_comment to utils.
authorAndreas Schneider <asn@samba.org>
Tue, 5 Mar 2013 14:54:44 +0000 (15:54 +0100)
committerDavid Disseldorp <ddiss@suse.de>
Tue, 5 Mar 2013 22:29:46 +0000 (23:29 +0100)
Reviewed-by: David Disseldorp <ddiss@samba.org>
lib/util/util_process.c [new file with mode: 0644]
lib/util/util_process.h [new file with mode: 0644]
lib/util/wscript_build
source3/Makefile.in

diff --git a/lib/util/util_process.c b/lib/util/util_process.c
new file mode 100644 (file)
index 0000000..6036e27
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ *  Unix SMB/CIFS implementation.
+ *
+ *  Process utils.
+ *
+ *  Copyright (c) 2013      Andreas Schneider <asn@samba.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "util_process.h"
+
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#endif
+
+int prctl_set_comment(const char *comment)
+{
+#if defined(HAVE_PRCTL) && defined(PR_SET_NAME)
+       return prctl(PR_SET_NAME, (unsigned long) comment, 0, 0, 0);
+#endif
+       return 0;
+}
diff --git a/lib/util/util_process.h b/lib/util/util_process.h
new file mode 100644 (file)
index 0000000..6e1ef07
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ *  Unix SMB/CIFS implementation.
+ *
+ *  Process utils.
+ *
+ *  Copyright (c) 2013      Andreas Schneider <asn@samba.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _SAMBA_UTIL_PROCESS_H
+#define _SAMBA_UTIL_PROCESS_H
+
+/**
+ * @brief Set the process comment name.
+ *
+ * @param[in]  comment  The comment to set which shouldn't be longer than 16
+ *                      16 characters (including \0).
+ *
+ * @return              -1 on error, 0 on success.
+ */
+int prctl_set_comment(const char *comment);
+
+#endif
index ac270ee4867e898224e3c6da1dc21e81ea5d3716..39a16135efea303abe2fb40ca3c25da2334d3f46 100755 (executable)
@@ -8,7 +8,7 @@ bld.SAMBA_LIBRARY('samba-util',
                     util_strlist.c util_paths.c idtree.c debug.c fault.c base64.c
                     util_str.c util_str_common.c substitute.c ms_fnmatch.c
                     server_id.c dprintf.c parmlist.c bitmap.c pidfile.c
-                    tevent_debug.c''',
+                    tevent_debug.c util_process.c''',
                   deps='DYNCONFIG',
                   public_deps='talloc tevent execinfo uid_wrapper pthread LIBCRYPTO charset util_setid',
                   public_headers='debug.h attr.h byteorder.h data_blob.h memory.h safe_string.h time.h talloc_stack.h xfile.h dlinklist.h samba_util.h string_wrappers.h',
index 90f12b741d664572fff28c3a82d75123e17a55d7..4b6918a838b87e6c875b09e8741e9cf818c8b1a4 100644 (file)
@@ -430,7 +430,7 @@ UTIL_OBJ = ../lib/util/rbtree.o ../lib/util/signal.o ../lib/util/time.o \
                   ../lib/util/genrand.o ../lib/util/util_net.o \
                   ../lib/util/become_daemon.o ../lib/util/system.o \
                   ../lib/util/tevent_unix.o ../lib/util/tevent_ntstatus.o \
-                  ../lib/util/tevent_werror.o \
+                  ../lib/util/tevent_werror.o ../lib/util/util_process.o\
                   lib/tevent_barrier.o \
                   ../lib/util/smb_threads.o ../lib/util/util_id.o \
                   ../lib/util/blocking.o ../lib/util/rfc1738.o \