add failure handling

This commit is contained in:
Olaf Rempel 2017-12-31 13:54:45 +01:00
parent 5ddc96811a
commit 43118a9844
1 changed files with 10 additions and 1 deletions

11
qnapd.c
View File

@ -139,6 +139,7 @@ int main(int argc, char *argv[])
while (1) { while (1) {
struct lcddev *lcd = NULL; struct lcddev *lcd = NULL;
struct picdev *pic = NULL; struct picdev *pic = NULL;
int abort = 0;
do { do {
const char *devicename = config_get_string("global", "lcddevice", NULL); const char *devicename = config_get_string("global", "lcddevice", NULL);
@ -149,10 +150,12 @@ int main(int argc, char *argv[])
lcd = lcd_open(devicename, lcdtimeout); lcd = lcd_open(devicename, lcdtimeout);
if (lcd == NULL) { if (lcd == NULL) {
abort = 1;
break; break;
} }
if (lcdpage_init(lcd) < 0) { if (lcdpage_init(lcd) < 0) {
abort = 1;
break; break;
} }
} }
@ -161,12 +164,15 @@ int main(int argc, char *argv[])
if (devicename != NULL) { if (devicename != NULL) {
pic = pic_open(devicename, lcd); pic = pic_open(devicename, lcd);
if (pic == NULL) { if (pic == NULL) {
abort = 1;
break; break;
} }
} }
if (diskwatch_init(lcd) < 0) if (diskwatch_init(lcd) < 0) {
abort = 1;
break; break;
}
/* exited on restart / SIGUSR1 */ /* exited on restart / SIGUSR1 */
event_loop(check_restart, NULL, NULL); event_loop(check_restart, NULL, NULL);
@ -185,6 +191,9 @@ int main(int argc, char *argv[])
config_free(); config_free();
if (abort)
break;
if (config_parse(config) < 0) if (config_parse(config) < 0)
break; break;