os: FatalError if -displayfd writes fail
authorKeith Packard <keithp@keithp.com>
Fri, 18 Apr 2014 22:00:30 +0000 (15:00 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 18 Apr 2014 23:30:17 +0000 (16:30 -0700)
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 <keithp@keithp.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
os/connection.c

index 5294e59..40d9ff3 100644 (file)
@@ -353,8 +353,10 @@ NotifyParentProcess(void)
 {
 #if !defined(WIN32)
     if (displayfd >= 0) {
-        write(displayfd, display, strlen(display));
-        write(displayfd, "\n", 1);
+        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;
     }