my_system/my_popen: detach the children from neutrino's terminal

Signed-off-by: Jacek Jendrzej <crashdvb@googlemail.com>


Origin commit data
------------------
Branch: ni/coolstream
Commit: 22be19a9b0
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2013-03-02 (Sat, 02 Mar 2013)



------------------
This commit was generated by Migit
This commit is contained in:
Stefan Seyfried
2013-03-02 20:01:24 +01:00
committed by Jacek Jendrzej
parent 32909385e9
commit 915c34bd15

View File

@@ -3,6 +3,9 @@
License: GPL 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 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or 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 */ case 0: /* child process */
for(i = 3; i < maxfd; i++) for(i = 3; i < maxfd; i++)
close(i); close(i);
if (setsid() == -1)
perror("my_system setsid");
if(execlp(cmd, cmd, arg1, arg2, arg3, arg4, arg5, arg6, (char*)NULL)) if(execlp(cmd, cmd, arg1, arg2, arg3, arg4, arg5, arg6, (char*)NULL))
{ {
std::string txt = "ERROR: my_system \"" + (std::string) cmd + "\""; 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(); int maxfd = getdtablesize();
for(int i = 3; i < maxfd; i++) for(int i = 3; i < maxfd; i++)
close(i); close(i);
if (setsid() == -1)
perror("my_popen setsid");
execl("/bin/sh", "sh", "-c", cmdstring, (char *)0); execl("/bin/sh", "sh", "-c", cmdstring, (char *)0);
exit(0); exit(0);
} }