]> Zhao Yanbai Git Server - minix.git/commitdiff
Don't close the master fd before returning if slave opens ok
authorBen Gras <ben@minix3.org>
Mon, 27 Mar 2006 11:08:53 +0000 (11:08 +0000)
committerBen Gras <ben@minix3.org>
Mon, 27 Mar 2006 11:08:53 +0000 (11:08 +0000)
lib/util/openpty.c

index 604b2bad56ab9d10271a53893ef2acb18c3d7c99..ec6db2525e8e4855ebd74d86b6170b4de9b1302a 100644 (file)
@@ -50,11 +50,10 @@ int openpty(int *amaster, int *aslave, char *name,
                if((*amaster = open(buff, O_RDWR)) >= 0) {
                  sprintf(tty_name, "%s/tty%c%c", DEV_DIR,
                        i, (j < 10) ? j + '0' : j + 'a' - 10);
-                 if((*aslave = open(tty_name, O_RDWR)) >= 0) {
+                 if((*aslave = open(tty_name, O_RDWR)) >= 0)
                        break;
-                 }
-                 close(*amaster);
                }
+               close(*amaster);
 
                j++;
                if (j == 16) break;