浏览代码

Check return value of pclose()

Laslo Hunhold 7 年之前
父节点
当前提交
b640cc489b
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      components/run_command.c

+ 4 - 1
components/run_command.c

@@ -16,7 +16,10 @@ run_command(const char *cmd)
 		return NULL;
 	}
 	p = fgets(buf, sizeof(buf) - 1, fp);
-	pclose(fp);
+	if (pclose(fp) < 0) {
+		warn("pclose '%s':", cmd);
+		return NULL;
+	}
 	if (!p) {
 		return NULL;
 	}