sprintf(command, "clrxdisasm --gpuType=%s -r %s", gpu_type, path);
p = popen(command, "r");
- if (!p || errno == ENOENT) {
- out << "clrxdisasm not found\n";
- } else {
- while (fgets(line, sizeof(line), p))
+ if (p) {
+ if (!fgets(line, sizeof(line), p)) {
+ out << "clrxdisasm not found\n";
+ pclose(p);
+ goto fail;
+ }
+
+ do {
out << line;
+ } while (fgets(line, sizeof(line), p));
+
pclose(p);
}