Commit 3be144ff authored by Jon TURNEY's avatar Jon TURNEY Committed by Mike Gabriel

Handle -displayfd and an explicit display number sensibly

commit bc348bd2c42f3f18786085ccef2f010eff5bf3d2 Author: Jon TURNEY <jon.turney@dronecode.org.uk> Date: Mon Mar 11 14:34:32 2013 +0000 Handle -displayfd and an explicit display number sensibly Handle -displayfd and an explicit display number sensibly, e.g. use the explicitly specified display number, and write it to the displayfd v2: displayfd might be 0, so use -1 as invalid value v3: Rebase for addition of NoListenAll flag Signed-off-by: 's avatarJon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: 's avatarKristian Høgsberg <krh@bitplanet.net> Backported-to-NX-by: 's avatarMike Gabriel <mike.gabriel@das-netzwerkteam.de>
parent 506aedbc
...@@ -149,7 +149,8 @@ int defaultColorVisualClass = -1; ...@@ -149,7 +149,8 @@ int defaultColorVisualClass = -1;
int monitorResolution = 0; int monitorResolution = 0;
char *display; char *display;
int displayfd; int displayfd = -1;
Bool explicit_display = FALSE;
CARD32 TimeOutValue = DEFAULT_TIMEOUT * MILLI_PER_SECOND; CARD32 TimeOutValue = DEFAULT_TIMEOUT * MILLI_PER_SECOND;
int argcGlobal; int argcGlobal;
......
...@@ -53,6 +53,7 @@ extern int argcGlobal; ...@@ -53,6 +53,7 @@ extern int argcGlobal;
extern char **argvGlobal; extern char **argvGlobal;
extern char *display; extern char *display;
extern int displayfd; extern int displayfd;
extern Bool explicit_display;
extern int defaultBackingStore; extern int defaultBackingStore;
extern Bool disableBackingStore; extern Bool disableBackingStore;
......
...@@ -361,8 +361,8 @@ void ...@@ -361,8 +361,8 @@ void
NotifyParentProcess(void) NotifyParentProcess(void)
{ {
#if !defined(WIN32) #if !defined(WIN32)
if (dynamic_display[0]) { if (displayfd >= 0) {
write(displayfd, dynamic_display, strlen(dynamic_display)); write(displayfd, display, strlen(display));
close(displayfd); close(displayfd);
} }
if (RunFromSmartParent) { if (RunFromSmartParent) {
...@@ -410,18 +410,17 @@ CreateWellKnownSockets(void) ...@@ -410,18 +410,17 @@ CreateWellKnownSockets(void)
FD_ZERO (&WellKnownConnections); FD_ZERO (&WellKnownConnections);
/* display is initialized to "0" by main(). It is then set to the display /* display is initialized to "0" by main(). It is then set to the display
* number if specified on the command line, or to NULL when the -displayfd * number if specified on the command line. */
* option is used. */
if (NoListenAll) { if (NoListenAll) {
ListenTransCount = 0; ListenTransCount = 0;
} }
else if (display) { else if ((displayfd < 0) || explicit_display) {
if (TryCreateSocket(atoi(display), &partial) && if (TryCreateSocket(atoi(display), &partial) &&
ListenTransCount >= 1) ListenTransCount >= 1)
if (!PartialNetwork && partial) if (!PartialNetwork && partial)
FatalError ("Failed to establish all listening sockets"); FatalError ("Failed to establish all listening sockets");
} }
else { /* -displayfd */ else { /* -displayfd and no explicit display number */
Bool found = 0; Bool found = 0;
for (i = 0; i < 65535 - X_TCP_PORT; i++) { for (i = 0; i < 65535 - X_TCP_PORT; i++) {
if (TryCreateSocket(i, &partial) && !partial) { if (TryCreateSocket(i, &partial) && !partial) {
......
...@@ -704,6 +704,7 @@ ProcessCommandLine(int argc, char *argv[]) ...@@ -704,6 +704,7 @@ ProcessCommandLine(int argc, char *argv[])
{ {
/* initialize display */ /* initialize display */
display = argv[i]; display = argv[i];
explicit_display = TRUE;
display++; display++;
if( ! VerifyDisplayName( display ) ) { if( ! VerifyDisplayName( display ) ) {
ErrorF("Bad display name: %s\n", display); ErrorF("Bad display name: %s\n", display);
...@@ -783,7 +784,6 @@ ProcessCommandLine(int argc, char *argv[]) ...@@ -783,7 +784,6 @@ ProcessCommandLine(int argc, char *argv[])
else if (strcmp(argv[i], "-displayfd") == 0) { else if (strcmp(argv[i], "-displayfd") == 0) {
if (++i < argc) { if (++i < argc) {
displayfd = atoi(argv[i]); displayfd = atoi(argv[i]);
display = NULL;
nolock = TRUE; nolock = TRUE;
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment