From 0d03bdb6ef605209e762c4736466c749c02f6b3d Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 2 Mar 2013 20:01:24 +0100 Subject: [PATCH] my_system/my_popen: detach the children from neutrino's terminal Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/b37a778012f73494b3cdb460032cdf471b5475d1 Author: Stefan Seyfried Date: 2013-03-02 (Sat, 02 Mar 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/system/helpers.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index 14a339404..cdf96ec09 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -3,6 +3,9 @@ License: GPL + (C) 2012-2013 the neutrino-hd developers + (C) 2012,2013 Stefan Seyfried + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or @@ -83,6 +86,8 @@ int my_system(const char * cmd, const char * arg1, const char * arg2, const char case 0: /* child process */ for(i = 3; i < maxfd; i++) close(i); + if (setsid() == -1) + perror("my_system setsid"); if(execlp(cmd, cmd, arg1, arg2, arg3, arg4, arg5, arg6, (char*)NULL)) { std::string txt = "ERROR: my_system \"" + (std::string) cmd + "\""; @@ -132,6 +137,8 @@ FILE* my_popen( pid_t& pid, const char *cmdstring, const char *type) int maxfd = getdtablesize(); for(int i = 3; i < maxfd; i++) close(i); + if (setsid() == -1) + perror("my_popen setsid"); execl("/bin/sh", "sh", "-c", cmdstring, (char *)0); exit(0); }