static const char *argv0 = NULL;
+static bool inMainloop = false;
static bool exitMainloop = false;
static const char *exitError = NULL;
if ((error != NULL) && (exitError == NULL))
exitError = strdup(error);
- exitMainloop = true;
+ if (inMainloop)
+ exitMainloop = true;
+ else {
+ // We're early in the startup. Assume we can just exit().
+ if (alertOnFatalError)
+ fl_alert("%s", exitError);
+ exit(EXIT_FAILURE);
+ }
}
bool should_exit()
vncServerName[VNCSERVERNAMELEN-1] = '\0';
} catch (rfb::Exception& e) {
vlog.error("%s", e.str());
- if (alertOnFatalError)
- fl_alert("%s", e.str());
- exit(EXIT_FAILURE);
+ exit_vncviewer(e.str());
}
}
}
// TRANSLATORS: "Parameters" are command line arguments, or settings
// from a file or the Windows registry.
vlog.error(_("Parameters -listen and -via are incompatible"));
- if (alertOnFatalError)
- fl_alert(_("Parameters -listen and -via are incompatible"));
- exit_vncviewer();
- return 1;
+ exit_vncviewer(_("Parameters -listen and -via are incompatible"));
+ return 1; /* Not reached */
}
#endif
}
} catch (rdr::Exception& e) {
vlog.error("%s", e.str());
- if (alertOnFatalError)
- fl_alert("%s", e.str());
- exit_vncviewer();
- return 1;
+ exit_vncviewer(e.str());
+ return 1; /* Not reached */
}
while (!listeners.empty()) {
CConn *cc = new CConn(vncServerName, sock);
+ inMainloop = true;
while (!exitMainloop)
run_mainloop();
+ inMainloop = false;
delete cc;