Browse Source

Fix some handling of failed display server connections

K. Lange 4 years ago
parent
commit
30e2c8d940
2 changed files with 11 additions and 3 deletions
  1. 6 2
      lib/pex.c
  2. 5 1
      lib/sdf.c

+ 6 - 2
lib/pex.c

@@ -44,7 +44,9 @@ FILE * pex_connect(char * target) {
 	char tmp[100];
 	sprintf(tmp, "/dev/pex/%s", target);
 	FILE * out = fopen(tmp, "r+");
-	setbuf(out, NULL);
+	if (out) {
+		setbuf(out, NULL);
+	}
 	return out;
 }
 
@@ -52,7 +54,9 @@ FILE * pex_bind(char * target) {
 	char tmp[100];
 	sprintf(tmp, "/dev/pex/%s", target);
 	FILE * out = fopen(tmp, "a+");
-	setbuf(out, NULL);
+	if (out) {
+		setbuf(out, NULL);
+	}
 	return out;
 }
 

+ 5 - 1
lib/sdf.c

@@ -63,10 +63,14 @@ static void _init_sdf(void) {
 	_font_cache = hashmap_create_int(10);
 	{
 		char tmp[100];
-		sprintf(tmp, "sys.%s.fonts", getenv("DISPLAY"));
+		char * display = getenv("DISPLAY");
+		if (!display) display = "compositor";
+		sprintf(tmp, "sys.%s.fonts", display);
 		_font_data = (char *)syscall_shm_obtain(tmp, &_font_data_size);
 	}
 
+	if (!_font_data_size) return;
+
 	load_font(&_font_data_thin, SDF_FONT_THIN);
 	load_font(&_font_data_bold, SDF_FONT_BOLD);
 	load_font(&_font_data_mono, SDF_FONT_MONO);