Make the shell module generate error messages if fork() or pipe() fail

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1369 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2009-02-03 19:42:40 +00:00
parent 607bb4e1ce
commit c7a98e7ec8
2 changed files with 11 additions and 6 deletions
+3 -5
View File
@@ -292,14 +292,12 @@ public:
m_iPid = -1;
}
CExecSock(const CString& sExec) : Csock() {
Execute(sExec);
}
int Execute(const CString & sExec) {
int iReadFD, iWriteFD;
m_iPid = popen2(iReadFD, iWriteFD, sExec);
ConnectFD(iReadFD, iWriteFD, "0.0.0.0:0");
if (m_iPid != -1) {
ConnectFD(iReadFD, iWriteFD, "0.0.0.0:0");
}
return(m_iPid);
}
void Kill(int iSignal)
+8 -1
View File
@@ -14,11 +14,18 @@ class CShellMod;
class CShellSock : public CExecSock {
public:
CShellSock(CShellMod* pShellMod, CClient* pClient, const CString& sExec) : CExecSock(sExec) {
CShellSock(CShellMod* pShellMod, CClient* pClient, const CString& sExec) : CExecSock() {
EnableReadLine();
m_pParent = pShellMod;
m_pClient = pClient;
if (Execute(sExec) == -1) {
CString s = "Failed to execute: ";
s += strerror(errno);
ReadLine(s);
return;
}
// Get rid of that write fd, we aren't going to use it
// (And clients expecting input will fail this way).
close(GetWSock());