mirror of
https://github.com/RubyMetric/chsrc
synced 2025-09-09 02:58:20 +08:00
添加 xy_run_get_status()
This commit is contained in:
parent
4cffe05711
commit
afc4ba3d06
23
lib/xy.h
23
lib/xy.h
@ -839,11 +839,25 @@ xy_run (const char *cmd, unsigned long n)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 执行命令,仅返回命令的执行状态
|
||||
*/
|
||||
int
|
||||
xy_run_get_status (char *cmd)
|
||||
{
|
||||
char * command = xy_str_to_quietcmd (cmd);
|
||||
|
||||
int status = system (command);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 捕获命令的输出
|
||||
*
|
||||
* @param[in] cmd 要执行的命令
|
||||
* @param[out] output 捕获的标准输出
|
||||
* @param[out] output 捕获的标准输出,
|
||||
* 为NULL时表示不关心stdout输出,但依然允许stderr输出
|
||||
*
|
||||
* @return 返回命令的执行状态
|
||||
*/
|
||||
@ -874,8 +888,11 @@ xy_run_capture (const char *cmd, char **output)
|
||||
buf[size] = '\0';
|
||||
|
||||
int status = pclose (stream);
|
||||
*output = buf;
|
||||
return status;
|
||||
|
||||
if (output)
|
||||
*output = buf;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user