From bd1aa8aa2f0d5e7c289a02b99a9b41211c891f13 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 2 Oct 2005 14:39:38 +0000 Subject: [PATCH] Two segfaults fixed for when there are multiple servers --- main.cc | 21 +++++++++++++++++++++ vconnect.cc | 7 +++++++ view.h | 3 +-- vserverselect.cc | 3 ++- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/main.cc b/main.cc index 490c8ca..d080782 100644 --- a/main.cc +++ b/main.cc @@ -87,6 +87,27 @@ int main(int argc, char** argv) logger->log("Core", Log::INFO, "Starting up..."); + // Daemonize if not -d + + if (!debugEnabled) + { + // Fork away + pid_t forkTest = fork(); + if (forkTest == -1) + { printf("Cannot fork (1).\n"); exit(1); } + if (forkTest != 0) _exit(0); // PID returned, I am the parent + // otherwise, I am the child + setsid(); + forkTest = fork(); + if (forkTest == -1) + { printf("Cannot fork (2).\n"); exit(1); } + if (forkTest != 0) _exit(0); // PID returned, I am the parent + // otherwise, I am the child + close(0); + close(1); + close(2); + } + // Set up signal handling ------------------------------------------------------------------------------------------ sighandler_t sigtest; diff --git a/vconnect.cc b/vconnect.cc index 562d57a..0b22d32 100644 --- a/vconnect.cc +++ b/vconnect.cc @@ -99,6 +99,13 @@ void VConnect::threadMethod() threadWaitForSignal(); } + if (!irun) + { + for(UINT k = 0; k < serverIPs.size(); k++) delete[] serverIPs[k]; + serverIPs.clear(); + return; + } + logger->log("VConnect", Log::NOTICE, "Connecting to server at %s", serverIPs[selectedServer]); vdr->setServerIP(serverIPs[selectedServer]); diff --git a/view.h b/view.h index c53a17f..430e9b0 100644 --- a/view.h +++ b/view.h @@ -59,12 +59,11 @@ class View : public Box Colour backgroundColour; + char* titleText; UCHAR titleBarOn; UCHAR borderOn; - protected: - char* titleText;//FIXME move this back to private Colour titleBarColour; View* parent; }; diff --git a/vserverselect.cc b/vserverselect.cc index a0055c5..91fb97f 100644 --- a/vserverselect.cc +++ b/vserverselect.cc @@ -42,7 +42,8 @@ VServerSelect::VServerSelect(std::vector* serverIPs) setTitleBarColour(Colour::TITLEBARBACKGROUND); setTitleText("Choose a VDR server"); - sl.setSurfaceOffset(30 + 5, 10); + sl.setSurface(surface); + sl.setSurfaceOffset(10, 30 + 5); sl.setDimensions(width - 20, height - 30 - 15); sl.addOption((*serverIPs)[0], 1); -- 2.39.5