From f4d7863f81e8314e6fc1fac1ea6ac54da89eea56 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Fri, 7 Apr 2017 15:26:45 +0200 Subject: Xserver/os/connection.c: Accompany display number with some human-readable (machine-parseable) text when -displayfd is set to STDERR. --- nx-X11/programs/Xserver/os/connection.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nx-X11/programs/Xserver/os/connection.c b/nx-X11/programs/Xserver/os/connection.c index 8a5eb756a..18f964add 100644 --- a/nx-X11/programs/Xserver/os/connection.c +++ b/nx-X11/programs/Xserver/os/connection.c @@ -79,6 +79,7 @@ SOFTWARE. #include #include #include +#include #ifndef WIN32 #include @@ -364,6 +365,14 @@ NotifyParentProcess(void) { #if !defined(WIN32) if (displayfd >= 0) { +#ifdef NXAGENT_SERVER + if (displayfd == STDERR_FILENO) + { + const char *msg = "Auto-detected display number is: DISPLAY=:"; + if (write(displayfd, msg, strlen(msg)) != strlen(msg)) + FatalError("Cannot write display number to fd %d\n", displayfd); + } +#endif if (write(displayfd, display, strlen(display)) != strlen(display)) FatalError("Cannot write display number to fd %d\n", displayfd); if (write(displayfd, "\n", 1) != 1) -- cgit v1.2.3 From ec185d7f7a5697d946c10c2dc58101dfe2d6aabf Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Fri, 7 Apr 2017 15:27:50 +0200 Subject: Xserver/os/connection.c: If -displayfd and an explicit display port number are given, use the explicit display number as a starting point for auto-detecting the next available display number. --- nx-X11/programs/Xserver/os/connection.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nx-X11/programs/Xserver/os/connection.c b/nx-X11/programs/Xserver/os/connection.c index 18f964add..1b01e1c46 100644 --- a/nx-X11/programs/Xserver/os/connection.c +++ b/nx-X11/programs/Xserver/os/connection.c @@ -427,7 +427,11 @@ CreateWellKnownSockets(void) if (NoListenAll) { ListenTransCount = 0; } +#ifndef NXAGENT_SERVER else if ((displayfd < 0) || explicit_display) { +#else + else if (displayfd < 0) { +#endif /* ! NXAGENT_SERVER */ if (TryCreateSocket(atoi(display), &partial) && ListenTransCount >= 1) if (!PartialNetwork && partial) @@ -435,7 +439,14 @@ CreateWellKnownSockets(void) } else { /* -displayfd and no explicit display number */ Bool found = 0; +#ifdef NXAGENT_SERVER + int i_offset = 0; + if (explicit_display) + i_offset = atoi(display); + for (i = i_offset; i < 65536 - X_TCP_PORT; i++) { +#else for (i = 0; i < 65536 - X_TCP_PORT; i++) { +#endif /* NXAGENT_SERVER */ if (TryCreateSocket(i, &partial) && !partial) { found = 1; break; -- cgit v1.2.3 From 9865f73beb421d389aeaaefc3c672bd3322e77f9 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Fri, 7 Apr 2017 16:39:27 +0200 Subject: man/nxagent.1: Document the nxagent specific usage pattern of the displayfd cmdline option. --- nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 b/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 index fd2ec0f84..1abec5753 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 +++ b/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 @@ -180,8 +180,23 @@ causes the server to generate a core dump on fatal errors. specifies a file descriptor in the launching process. Rather than specifying a display number, the X server will attempt to listen on successively higher display numbers, and upon finding a free one, will write the port number back -on this file descriptor as a newline-terminated string. The \-pn option is -ignored when using \-displayfd. +on this file descriptor as a newline-terminated string. The \fB\-pn\fR option is +ignored when using \fB\-displayfd\fR. + +nxagent specific: + +(1) Other than in X.org's Xserver, you can use \fB\-displayfd\fR in +conjunction with an explicit display number. If the explicit display number +is not available (i.e., already in use), nxagent tries to figure out the next +available display number, + +e.g.: + + \fBnxagent\fR \fI\-displayfd 2 :50\fR + +(2) If -displayfd is given with equaling 2 (STDERR), then the +display number string written to STDERR is beautified with some human-readable +(machine-parseable) text. .TP 8 .B \-deferglyphs \fIwhichfonts\fP specifies the types of fonts for which the server should attempt to use -- cgit v1.2.3