We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
xy_run_get_status()
1 parent 4cffe05 commit afc4ba3Copy full SHA for afc4ba3
1 file changed
lib/xy.h
@@ -839,11 +839,25 @@ xy_run (const char *cmd, unsigned long n)
839
}
840
841
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
855
/**
856
* @brief 捕获命令的输出
857
*
858
* @param[in] cmd 要执行的命令
- * @param[out] output 捕获的标准输出
859
+ * @param[out] output 捕获的标准输出,
860
+ * 为NULL时表示不关心stdout输出,但依然允许stderr输出
861
862
* @return 返回命令的执行状态
863
*/
@@ -874,8 +888,11 @@ xy_run_capture (const char *cmd, char **output)
874
888
buf[size] = '\0';
875
889
876
890
int status = pclose (stream);
877
- *output = buf;
878
- return status;
891
892
+ if (output)
893
+ *output = buf;
894
895
879
896
880
897
881
898
0 commit comments