setproctitle.c 1.4 KB

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