2023-02-23 15:08:08 +08:00
|
|
|
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
|
2023-02-14 18:13:19 +08:00
|
|
|
//
|
2023-02-23 15:08:08 +08:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2022-04-24 14:52:13 +08:00
|
|
|
|
|
|
|
#ifndef PROCESSINFO_H
|
|
|
|
#define PROCESSINFO_H
|
|
|
|
|
|
|
|
#include "process.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
// 进程信息
|
|
|
|
class ProcessInfo
|
|
|
|
{
|
|
|
|
public:
|
2022-07-21 15:59:37 +08:00
|
|
|
explicit ProcessInfo(int pid);
|
|
|
|
explicit ProcessInfo(std::vector<std::string> &cmd);
|
|
|
|
virtual ~ProcessInfo();
|
2022-04-24 14:52:13 +08:00
|
|
|
|
|
|
|
std::string getEnv(std::string key);
|
|
|
|
std::vector<std::string> getCmdLine();
|
|
|
|
std::vector<std::string> getArgs();
|
|
|
|
int getPid();
|
|
|
|
int getPpid();
|
2022-05-27 21:03:41 +08:00
|
|
|
bool initWithPid();
|
2022-06-27 10:15:19 +08:00
|
|
|
bool isValid();
|
2022-04-24 14:52:13 +08:00
|
|
|
std::string getExe();
|
|
|
|
std::string getOneCommandLine();
|
|
|
|
std::string getShellScriptLines();
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string getJoinedExeArgs();
|
|
|
|
|
2022-06-27 10:15:19 +08:00
|
|
|
std::vector<std::string> m_cmdLine;
|
|
|
|
std::vector<std::string> m_args;
|
|
|
|
std::string m_exe;
|
|
|
|
std::string m_cwd;
|
2022-04-24 14:52:13 +08:00
|
|
|
|
2022-06-27 10:15:19 +08:00
|
|
|
bool m_hasPid;
|
|
|
|
bool m_isValid;
|
|
|
|
Process m_process;
|
2022-04-24 14:52:13 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PROCESSINFO_H
|