File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -839,11 +839,25 @@ xy_run (const char *cmd, unsigned long n)
839839}
840840
841841
842+ /**
843+ * @brief 执行命令,仅返回命令的执行状态
844+ */
845+ int
846+ xy_run_get_status (char * cmd )
847+ {
848+ char * command = xy_str_to_quietcmd (cmd );
849+
850+ int status = system (command );
851+ return status ;
852+ }
853+
854+
842855/**
843856 * @brief 捕获命令的输出
844857 *
845858 * @param[in] cmd 要执行的命令
846- * @param[out] output 捕获的标准输出
859+ * @param[out] output 捕获的标准输出,
860+ * 为NULL时表示不关心stdout输出,但依然允许stderr输出
847861 *
848862 * @return 返回命令的执行状态
849863 */
@@ -874,8 +888,11 @@ xy_run_capture (const char *cmd, char **output)
874888 buf [size ] = '\0' ;
875889
876890 int status = pclose (stream );
877- * output = buf ;
878- return status ;
891+
892+ if (output )
893+ * output = buf ;
894+
895+ return status ;
879896}
880897
881898
You can’t perform that action at this time.
0 commit comments