xref: /netbsd-src/external/gpl3/binutils.old/dist/libiberty/setproctitle.c (revision e992f068c547fd6e84b3f104dc2340adcc955732)
116dce513Schristos /* Set the title of a process.
2*e992f068Schristos    Copyright (C) 2010-2022 Free Software Foundation, Inc.
316dce513Schristos 
416dce513Schristos This file is part of the libiberty library.
516dce513Schristos Libiberty is free software; you can redistribute it and/or
616dce513Schristos modify it under the terms of the GNU Library General Public
716dce513Schristos License as published by the Free Software Foundation; either
816dce513Schristos version 2 of the License, or (at your option) any later version.
916dce513Schristos 
1016dce513Schristos Libiberty is distributed in the hope that it will be useful,
1116dce513Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of
1216dce513Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1316dce513Schristos Library General Public License for more details.
1416dce513Schristos 
1516dce513Schristos You should have received a copy of the GNU Library General Public
1616dce513Schristos License along with libiberty; see the file COPYING.LIB.  If not,
1716dce513Schristos write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
1816dce513Schristos Boston, MA 02110-1301, USA.  */
1916dce513Schristos 
2016dce513Schristos #ifdef HAVE_CONFIG_H
2116dce513Schristos #include "config.h"
2216dce513Schristos #endif
2316dce513Schristos #ifdef HAVE_SYS_PRCTL_H
2416dce513Schristos #include <sys/types.h>
2516dce513Schristos #include <sys/prctl.h>
2616dce513Schristos #endif
2716dce513Schristos #include "ansidecl.h"
2816dce513Schristos 
2916dce513Schristos /*
3016dce513Schristos 
3116dce513Schristos @deftypefn Supplemental void setproctitle (const char *@var{fmt}, ...)
3216dce513Schristos 
3316dce513Schristos Set the title of a process to @var{fmt}. va args not supported for now,
3416dce513Schristos but defined for compatibility with BSD.
3516dce513Schristos 
3616dce513Schristos @end deftypefn
3716dce513Schristos 
3816dce513Schristos */
3916dce513Schristos 
4016dce513Schristos void
setproctitle(const char * name ATTRIBUTE_UNUSED,...)4116dce513Schristos setproctitle (const char *name ATTRIBUTE_UNUSED, ...)
4216dce513Schristos {
4316dce513Schristos #ifdef PR_SET_NAME
4416dce513Schristos   /* On GNU/Linux this sets the top visible "comm", but not
4516dce513Schristos      necessarily the name visible in ps. */
4616dce513Schristos   prctl (PR_SET_NAME, name);
4716dce513Schristos #endif
4816dce513Schristos }
49