summaryrefslogtreecommitdiffstats
path: root/client/foreign_menu.cpp
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2012-03-05 22:39:24 +0100
committerMarc-André Lureau <marcandre.lureau@redhat.com>2012-03-05 22:52:27 +0100
commit1ab589f39ed0429ca08f13f093161098ac511ef1 (patch)
treef9541a81a60ac00a7371fef53fc42d0e9cc4465a /client/foreign_menu.cpp
parent01d565ff5472201d082e9bca5fa017694d4013ef (diff)
Use SPICE_FOREIGN_MENU_SOCKET if it's available
If specified, use SPICE_FOREIGN_MENU_SOCKET environment variable over snprintf(pipe_name, PIPE_NAME_MAX_LEN, PIPE_NAME, Platform::get_process_id()); since it's impossible to guess the client pid when spice-xpi launches the client as a grand-child (via script etc). This is also more aligned with the way we handle SPICE_XPI_SOCKET location.
Diffstat (limited to 'client/foreign_menu.cpp')
-rw-r--r--client/foreign_menu.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/client/foreign_menu.cpp b/client/foreign_menu.cpp
index faef4c27..1010bfba 100644
--- a/client/foreign_menu.cpp
+++ b/client/foreign_menu.cpp
@@ -44,7 +44,13 @@ ForeignMenu::ForeignMenu(ForeignMenuInterface *handler, bool active)
char pipe_name[PIPE_NAME_MAX_LEN];
ASSERT(_handler != NULL);
- snprintf(pipe_name, PIPE_NAME_MAX_LEN, PIPE_NAME, Platform::get_process_id());
+#ifndef WIN32
+ const char *p_socket = getenv("SPICE_FOREIGN_MENU_SOCKET");
+ if (p_socket)
+ strncpy(pipe_name, p_socket, sizeof(pipe_name));
+ else
+#endif
+ snprintf(pipe_name, PIPE_NAME_MAX_LEN, PIPE_NAME, Platform::get_process_id());
LOG_INFO("Creating a foreign menu connection %s", pipe_name);
_foreign_menu = NamedPipe::create(pipe_name, *this);
if (!_foreign_menu) {