1 Star 0 Fork 0

坐公交也用券/gcs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Process.go 866 Bytes
一键复制 编辑 原始数据 按行查看 历史
坐公交也用券 提交于 2024-12-19 11:21 +08:00 . 完善注释,升级依赖库
package gcs
// ProcessIsRunning 检查指定命令的进程是否正在运行。
// 参数:
//
// command (string): 需要检测的命令名称。
//
// 返回值:
//
// bool: 如果进程正在运行,则返回true;否则返回false。
func (api *ApiShell) ProcessIsRunning(command string) bool {
// 如果启用了调试模式,则打印调试信息。
if api.Debug {
logs.Debug("正在通过命令名称检测进程运行状态: ", command)
}
// 执行命令来检查进程状态。
api.RunShell("ps -C ", command)
// 如果没有错误发生并且退出代码为0,则表示进程正在运行。
if api.Err == nil {
if api.ExitCode == 0 {
return true
}
}
// 打印调试信息,显示退出代码。
logs.Debug("Exit Code: %d", api.ExitCode)
// 如果退出代码不为0,则表示进程未运行,返回false。
return false
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/liumou_site/gcs.git
git@gitee.com:liumou_site/gcs.git
liumou_site
gcs
gcs
master

搜索帮助