From a0197ad7f1053bbb66931c2de28f046f4b1d25f4 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 4 Aug 2014 17:44:12 +0200 Subject: [PATCH] Fixed stream startup forking incorrectly. --- lib/stream.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/stream.cpp b/lib/stream.cpp index d1297e3f..7375df01 100644 --- a/lib/stream.cpp +++ b/lib/stream.cpp @@ -76,11 +76,14 @@ bool Util::Stream::getLive(std::string streamname) { } int pid = fork(); - if (pid) { + if (pid == -1) { + FAIL_MSG("Forking process for stream %s failed: %s", streamname.c_str(), strerror(errno)); + return false; + } + if (pid == 0){ execvp(argv[0], argv); + FAIL_MSG("Starting process %s for stream %s failed: %s", argv[0], streamname.c_str(), strerror(errno)); _exit(42); - } else if (pid == -1) { - perror("Could not start vod"); } return true; } @@ -101,11 +104,14 @@ bool Util::Stream::getVod(std::string filename, std::string streamname) { char * const argv[] = {(char *)player_bin.c_str(), (char *)"-p", (char *)"-s", (char *)streamname.c_str(), (char *)filename.c_str(), (char *)0}; int pid = fork(); - if (pid) { + if (pid == -1) { + FAIL_MSG("Forking process for stream %s failed: %s", streamname.c_str(), strerror(errno)); + return false; + } + if (pid == 0){ execvp(argv[0], argv); + FAIL_MSG("Starting process %s for stream %s failed: %s", argv[0], streamname.c_str(), strerror(errno)); _exit(42); - } else if (pid == -1) { - perror("Could not start vod"); } return true; }