ZNC
trunk
Toggle main menu visibility
Loading...
Searching...
No Matches
include
znc
ExecSock.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2004-2025 ZNC, see the NOTICE file for details.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#ifndef ZNC_EXECSOCK_H
18
#define ZNC_EXECSOCK_H
19
20
#include <znc/zncconfig.h>
21
#include <
znc/Socket.h
>
22
#include <signal.h>
23
25
class
CExecSock
:
public
CZNCSock
{
26
public
:
27
CExecSock
() :
CZNCSock
(0), m_iPid(-1) {}
28
29
int
Execute
(
const
CString
& sExec) {
30
int
iReadFD, iWriteFD;
31
m_iPid =
popen2
(iReadFD, iWriteFD, sExec);
32
if
(m_iPid != -1) {
33
ConnectFD
(iReadFD, iWriteFD,
"0.0.0.0:0"
);
34
}
35
return
(m_iPid);
36
}
37
void
Kill
(
int
iSignal) {
38
kill(m_iPid, iSignal);
39
Close
();
40
}
41
virtual
~CExecSock
() {
42
close2
(m_iPid,
GetRSock
(),
GetWSock
());
43
SetRSock
(-1);
44
SetWSock
(-1);
45
}
46
47
int
popen2
(
int
& iReadFD,
int
& iWriteFD,
const
CString
& sCommand);
48
void
close2
(
int
iPid,
int
iReadFD,
int
iWriteFD);
49
50
private
:
51
int
m_iPid;
52
};
53
54
#endif
// !ZNC_EXECSOCK_H
Socket.h
CExecSock::Execute
int Execute(const CString &sExec)
Definition
ExecSock.h:29
CExecSock::popen2
int popen2(int &iReadFD, int &iWriteFD, const CString &sCommand)
CExecSock::Kill
void Kill(int iSignal)
Definition
ExecSock.h:37
CExecSock::CExecSock
CExecSock()
Definition
ExecSock.h:27
CExecSock::~CExecSock
virtual ~CExecSock()
Definition
ExecSock.h:41
CExecSock::close2
void close2(int iPid, int iReadFD, int iWriteFD)
CString
String class that is used inside ZNC.
Definition
ZNCString.h:50
CZNCSock::CZNCSock
CZNCSock(int timeout=60)
Csock::GetWSock
cs_sock_t & GetWSock()
Csock::SetWSock
void SetWSock(cs_sock_t iSock)
Csock::SetRSock
void SetRSock(cs_sock_t iSock)
Csock::Close
void Close(ECloseType eCloseType=CLT_NOW)
just mark us as closed, the parent can pick it up
Csock::GetRSock
cs_sock_t & GetRSock()
returns a reference to the sock
Csock::ConnectFD
bool ConnectFD(int iReadFD, int iWriteFD, const CS_STRING &sName, bool bIsSSL=false, ETConn eDirection=INBOUND)
Tie this guy to an existing real file descriptor.
Generated by
1.17.0