network: reap child in all cases

parent fa3a5b22
...@@ -2126,13 +2126,13 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna ...@@ -2126,13 +2126,13 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
if (bytes < 0) { if (bytes < 0) {
SYSERROR("Failed to read from pipe file descriptor"); SYSERROR("Failed to read from pipe file descriptor");
close(pipefd[0]); close(pipefd[0]);
return -1; } else {
buffer[bytes - 1] = '\0';
} }
buffer[bytes - 1] = '\0';
ret = wait_for_pid(child); ret = wait_for_pid(child);
close(pipefd[0]); close(pipefd[0]);
if (ret != 0) { if (ret != 0 || bytes < 0) {
ERROR("lxc-user-nic failed to configure requested network: %s", ERROR("lxc-user-nic failed to configure requested network: %s",
buffer[0] != '\0' ? buffer : "(null)"); buffer[0] != '\0' ? buffer : "(null)");
return -1; return -1;
...@@ -2267,19 +2267,18 @@ static int lxc_delete_network_unpriv_exec(const char *lxcpath, const char *lxcna ...@@ -2267,19 +2267,18 @@ static int lxc_delete_network_unpriv_exec(const char *lxcpath, const char *lxcna
if (bytes < 0) { if (bytes < 0) {
SYSERROR("Failed to read from pipe file descriptor."); SYSERROR("Failed to read from pipe file descriptor.");
close(pipefd[0]); close(pipefd[0]);
return -1; } else {
buffer[bytes - 1] = '\0';
} }
buffer[bytes - 1] = '\0';
if (wait_for_pid(child) != 0) { ret = wait_for_pid(child);
close(pipefd[0]);
if (ret != 0 || bytes < 0) {
ERROR("lxc-user-nic failed to delete requested network: %s", ERROR("lxc-user-nic failed to delete requested network: %s",
buffer[0] != '\0' ? buffer : "(null)"); buffer[0] != '\0' ? buffer : "(null)");
close(pipefd[0]);
return -1; return -1;
} }
close(pipefd[0]);
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment