summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/machine/machinectl.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index ab9060ab99..b3a70188a4 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -452,10 +452,7 @@ static int openpt_in_namespace(pid_t pid, int flags) {
pair[1] = -1;
r = wait_for_terminate(child, &si);
- if (r < 0 || si.si_code != CLD_EXITED || si.si_status != EXIT_SUCCESS || master < 0) {
-
- if (master >= 0)
- close_nointr_nofail(master);
+ if (r < 0 || si.si_code != CLD_EXITED || si.si_status != EXIT_SUCCESS) {
return r < 0 ? r : -EIO;
}
@@ -479,6 +476,9 @@ static int openpt_in_namespace(pid_t pid, int flags) {
master = fds[0];
}
+ if (master < 0)
+ return -EIO;
+
return master;
}