setproctitle.c revision 1.1.1.2 1 1.1 christos /* Set the title of a process.
2 1.1.1.2 christos Copyright (C) 2010, 2011 Free Software Foundation, Inc.
3 1.1 christos
4 1.1 christos This file is part of the libiberty library.
5 1.1 christos Libiberty is free software; you can redistribute it and/or
6 1.1 christos modify it under the terms of the GNU Library General Public
7 1.1 christos License as published by the Free Software Foundation; either
8 1.1 christos version 2 of the License, or (at your option) any later version.
9 1.1 christos
10 1.1 christos Libiberty is distributed in the hope that it will be useful,
11 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
12 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 1.1 christos Library General Public License for more details.
14 1.1 christos
15 1.1 christos You should have received a copy of the GNU Library General Public
16 1.1 christos License along with libiberty; see the file COPYING.LIB. If not,
17 1.1 christos write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
18 1.1 christos Boston, MA 02110-1301, USA. */
19 1.1 christos
20 1.1 christos #ifdef HAVE_CONFIG_H
21 1.1 christos #include "config.h"
22 1.1 christos #endif
23 1.1.1.2 christos #ifdef HAVE_SYS_PRCTL_H
24 1.1.1.2 christos #include <sys/types.h>
25 1.1 christos #include <sys/prctl.h>
26 1.1 christos #endif
27 1.1 christos #include "ansidecl.h"
28 1.1 christos
29 1.1 christos /*
30 1.1 christos
31 1.1.1.2 christos @deftypefn Supplemental void setproctitle (const char *@var{fmt}, ...)
32 1.1 christos
33 1.1 christos Set the title of a process to @var{fmt}. va args not supported for now,
34 1.1 christos but defined for compatibility with BSD.
35 1.1 christos
36 1.1 christos @end deftypefn
37 1.1 christos
38 1.1 christos */
39 1.1 christos
40 1.1 christos void
41 1.1 christos setproctitle (const char *name ATTRIBUTE_UNUSED, ...)
42 1.1 christos {
43 1.1.1.2 christos #ifdef PR_SET_NAME
44 1.1.1.2 christos /* On GNU/Linux this sets the top visible "comm", but not
45 1.1.1.2 christos necessarily the name visible in ps. */
46 1.1 christos prctl (PR_SET_NAME, name);
47 1.1 christos #endif
48 1.1 christos }
49