From a95cfdf48aa5102e16611360917c60b9354192fa Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 15 Mar 2017 15:46:32 +0000 Subject: os: FatalError if -displayfd writes fail AND Clear the -displayfd option after closing the file commit d72f691c0c9cace857975a6608a4cb431c8b6846 Author: Keith Packard Date: Fri Apr 18 15:00:30 2014 -0700 os: FatalError if -displayfd writes fail When the server is started with the -displayfd option, check to make sure that the writes succeed and give up running if they don't. Signed-off-by: Keith Packard Reviewed-by: Jamey Sharp commit 4957e986841225e9984daca76f1a0ee08df125bb Author: Keith Packard Date: Fri Apr 18 15:00:35 2014 -0700 os: Clear the -displayfd option after closing the file Failing to clear this means that we'll attempt to write the display number to a random file descriptor on subsequent X server generations. Signed-off-by: Keith Packard Reviewed-by: Jamey Sharp Backported-to-NX-by: Mike Gabriel --- nx-X11/programs/Xserver/os/connection.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/os/connection.c b/nx-X11/programs/Xserver/os/connection.c index 940b0bd75..8a5eb756a 100644 --- a/nx-X11/programs/Xserver/os/connection.c +++ b/nx-X11/programs/Xserver/os/connection.c @@ -364,8 +364,12 @@ NotifyParentProcess(void) { #if !defined(WIN32) if (displayfd >= 0) { - write(displayfd, display, strlen(display)); - close(displayfd); + if (write(displayfd, display, strlen(display)) != strlen(display)) + FatalError("Cannot write display number to fd %d\n", displayfd); + if (write(displayfd, "\n", 1) != 1) + FatalError("Cannot write display number to fd %d\n", displayfd); + close(displayfd); + displayfd = -1; } if (RunFromSmartParent) { if (ParentProcess > 1) { -- cgit v1.2.3