diff --git a/usr.sbin/pmcstudy/pmcstudy.c b/usr.sbin/pmcstudy/pmcstudy.c index 69d926a05e5d..6f5b6ba856a7 100644 --- a/usr.sbin/pmcstudy/pmcstudy.c +++ b/usr.sbin/pmcstudy/pmcstudy.c @@ -2249,6 +2249,10 @@ process_file(char *filename) if (filename == NULL) { io = my_popen(command, "r", &pid_of_command); + if (io == NULL) { + printf("Can't popen the command %s\n", command); + return; + } } else { io = fopen(filename, "r"); if (io == NULL) { @@ -2261,8 +2265,10 @@ process_file(char *filename) if (cnts == NULL) { /* Nothing we can do */ printf("Nothing to do -- no counters built\n"); - if (io) { + if (filename) { fclose(io); + } else { + my_pclose(io, pid_of_command); } return; }