summaryrefslogtreecommitdiffstats
path: root/compat/forkpty-aix.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2014-09-23 10:50:11 +0100
committerNicholas Marriott <nicholas.marriott@gmail.com>2014-09-23 10:50:11 +0100
commit16670410ca24e43eff88824aacb988432afc8691 (patch)
tree6520c753eeacc629bf0abf15ef3d04bbab725893 /compat/forkpty-aix.c
parent054a825ee24e2a2ea294ea2a259af7eeb8ae947e (diff)
I broke last change, fix so it works, from J Raynor.
Diffstat (limited to 'compat/forkpty-aix.c')
-rw-r--r--compat/forkpty-aix.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/compat/forkpty-aix.c b/compat/forkpty-aix.c
index 78e5f7e2..7638c528 100644
--- a/compat/forkpty-aix.c
+++ b/compat/forkpty-aix.c
@@ -30,7 +30,7 @@
pid_t
forkpty(int *master, unused char *name, struct termios *tio, struct winsize *ws)
{
- int slave, fd, pipe_fd[2];
+ int slave = -1, fd, pipe_fd[2];
char *path, dummy;
pid_t pid;
@@ -38,7 +38,7 @@ forkpty(int *master, unused char *name, struct termios *tio, struct winsize *ws)
return (-1);
if ((*master = open("/dev/ptc", O_RDWR|O_NOCTTY)) == -1)
- return (-1);
+ goto out;
if ((path = ttyname(*master)) == NULL)
goto out;
@@ -95,19 +95,19 @@ forkpty(int *master, unused char *name, struct termios *tio, struct winsize *ws)
return (0);
}
- close(pipe_fd[0]);
- close(pipe_fd[1]);
-
close(slave);
- return (pid);
-out:
close(pipe_fd[0]);
close(pipe_fd[1]);
+ return (pid);
+out:
if (*master != -1)
close(*master);
if (slave != -1)
close(slave);
+
+ close(pipe_fd[0]);
+ close(pipe_fd[1]);
return (-1);
}