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 <keithp@keithp.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
This commit is contained in:
Keith Packard 2014-04-18 15:00:30 -07:00
parent 4957e98684
commit d72f691c0c

View 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;
}