Service_NSSM/CC_SDK/Include/Module/IO/CCProcess.h

61 lines
1.0 KiB
C
Raw Permalink Normal View History

2025-09-30 16:24:15 +08:00
#ifndef CC_PROCESS_H
#define CC_PROCESS_H
2025-09-27 14:24:18 +08:00
#include "CC.h"
2025-09-30 16:24:15 +08:00
#ifdef _WIN32
#include "windows.h"
#elif __linux__
#endif
2025-09-27 14:24:18 +08:00
#define CC_PROCESS_MAX_BUFFER_SIZE 1024
2025-09-30 16:24:15 +08:00
#ifdef _WIN32
#elif __linux__
#endif
2025-09-27 14:24:18 +08:00
namespace CTL{
2025-09-30 16:24:15 +08:00
#ifdef _WIN32
#elif __linux__
#endif
class Process{
2025-09-27 14:24:18 +08:00
std::queue<String> ReadBuffer;
2025-09-30 16:24:15 +08:00
String ExeName;
String Working;
2025-09-27 14:24:18 +08:00
bool Flag = false;
2025-09-30 16:24:15 +08:00
#ifdef _WIN32
HANDLE hReadPipe{}, hWritePipe{};
SECURITY_ATTRIBUTES sa{};
PROCESS_INFORMATION pi{};
#elif __linux__
int pipefd[2]{};
pid_t pid{};
#endif
2025-09-27 14:24:18 +08:00
public:
Process() = default;
2025-09-30 16:24:15 +08:00
Process(const Process& p);
void Command(const String& CommandExe);
void SetWorking(const String& WorkPath);
bool Start(bool isolation = false);
2025-09-27 14:24:18 +08:00
void Stop();
2025-09-30 16:24:15 +08:00
[[nodiscard]] ByteArray ReadLineBuffer() const;
[[nodiscard]] bool IsRunning() const;
2025-09-27 14:24:18 +08:00
static void Execute(const String& Command);
2025-09-30 16:24:15 +08:00
static void StopProcess(String& Name);
2025-09-27 14:24:18 +08:00
private:
public:
};
}
#endif