Add global helpers my_system() and my_popen()

Origin commit data
------------------
Commit: b92660259c
Author: FlatTV <FlatTV@gmx.de>
Date: 2012-08-30 (Thu, 30 Aug 2012)
This commit is contained in:
FlatTV
2012-08-30 07:19:52 +02:00
committed by vanhofen
parent 391362267e
commit 860e0b99ca
5 changed files with 169 additions and 33 deletions

View File

@@ -216,32 +216,6 @@ void CNetworkConfig::commitConfig(void)
}
}
int mysystem(const char * cmd, const char * arg1, const char * arg2)
{
int i;
pid_t pid;
int maxfd = getdtablesize();// sysconf(_SC_OPEN_MAX);
switch (pid = vfork())
{
case -1: /* can't fork */
perror("vfork");
return -1;
case 0: /* child process */
for(i = 3; i < maxfd; i++)
close(i);
if(execlp(cmd, cmd, arg1, arg2, NULL))
{
perror("exec");
}
exit(0);
default: /* parent returns to calling process */
break;
}
waitpid(pid, 0, 0);
return 0;
}
void CNetworkConfig::startNetwork(void)
{
std::string cmd = "/sbin/ifup " + ifname;