close master/slave pty in the shell process.

master
Aurélien Aptel 2010-08-26 21:36:21 +02:00
parent 5c93f399c5
commit e8c13ebe80
1 changed files with 4 additions and 2 deletions

6
st.c
View File

@ -247,7 +247,7 @@ ttynew(void) {
if((m = posix_openpt(O_RDWR | O_NOCTTY)) < 0) if((m = posix_openpt(O_RDWR | O_NOCTTY)) < 0)
die("openpt failed: %s\n", SERRNO); die("openpt failed: %s\n", SERRNO);
if(grantpt(m) < 0) if(grantpt(m) < 0)
die("grandpt failed: %s\n", SERRNO); die("grantpt failed: %s\n", SERRNO);
if(unlockpt(m) < 0) if(unlockpt(m) < 0)
die("unlockpt failed: %s\n", SERRNO); die("unlockpt failed: %s\n", SERRNO);
if(!(pts = ptsname(m))) if(!(pts = ptsname(m)))
@ -265,7 +265,9 @@ ttynew(void) {
dup2(s, STDOUT_FILENO); dup2(s, STDOUT_FILENO);
dup2(s, STDERR_FILENO); dup2(s, STDERR_FILENO);
if(ioctl(s, TIOCSCTTY, NULL) < 0) if(ioctl(s, TIOCSCTTY, NULL) < 0)
die("ioctl TTIOCSTTY failed: %s\n", SERRNO); die("ioctl TIOCSCTTY failed: %s\n", SERRNO);
close(s);
close(m);
execsh(); execsh();
break; break;
default: default: