Fix popen/pclose usage

This commit is contained in:
Radon Rosborough 2021-03-21 14:15:45 -07:00
parent 4a79b95efc
commit 2e12413d54
1 changed files with 5 additions and 1 deletions

View File

@ -81,7 +81,7 @@ void wait_alarm(int signum)
void wait(char *uuid)
{
char *cmdline;
if (asprintf(&cmdline, "docker inspect riju-session-%s", uuid) < 0)
if (asprintf(&cmdline, "docker inspect riju-session-%s >/dev/null 2>&1", uuid) < 0)
die("asprintf failed");
struct timespec ts;
ts.tv_sec = 0;
@ -92,6 +92,10 @@ void wait(char *uuid)
FILE *proc = popen(cmdline, "r");
if (proc == NULL)
die("popen failed");
char buf[1024];
while (fgets(buf, 1024, proc) != NULL);
if (ferror(proc))
die("fgets failed");
int status = pclose(proc);
if (status < 0)
die("pclose failed");