Bug 1908670 - Home and newtab topic personalization needs region controls r=home...
[gecko.git] / ipc / glue / SetProcessTitle.cpp
blob4d929fb53c56b3ae5115b8fe99c8a7579cf03f27
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "mozilla/ipc/SetProcessTitle.h"
8 #include "nsString.h"
10 #ifdef XP_LINUX
12 # include "base/set_process_title_linux.h"
13 # define HAVE_SETPROCTITLE
14 # define HAVE_SETPROCTITLE_INIT
16 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
17 defined(__DragonFly__)
19 # include <sys/types.h>
20 # include <unistd.h>
21 # define HAVE_SETPROCTITLE
23 #endif
25 namespace mozilla {
27 void SetProcessTitle(const std::vector<std::string>& aNewArgv) {
28 #ifdef HAVE_SETPROCTITLE
29 nsAutoCStringN<1024> buf;
31 bool firstArg = true;
32 for (const std::string& arg : aNewArgv) {
33 if (firstArg) {
34 firstArg = false;
35 } else {
36 buf.Append(' ');
38 buf.Append(arg.c_str());
41 setproctitle("-%s", buf.get());
42 #endif
45 void SetProcessTitleInit(char** aOrigArgv) {
46 #ifdef HAVE_SETPROCTITLE_INIT
47 setproctitle_init(aOrigArgv);
48 #endif
51 } // namespace mozilla