chiark / gitweb /
machinectl: fix success check when getting pty from within container
authorLennart Poettering <lennart@poettering.net>
Mon, 23 Dec 2013 18:15:43 +0000 (19:15 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 23 Dec 2013 19:25:57 +0000 (20:25 +0100)
src/machine/machinectl.c

index ab9060a..b3a7018 100644 (file)
@@ -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;
 }