diff options
| -rw-r--r-- | st.c | 5 |
1 files changed, 3 insertions, 2 deletions
| @@ -793,14 +793,15 @@ ttynew(const char *line, char *cmd, const char *out, char **args) | |||
| 793 | break; | 793 | break; |
| 794 | case 0: | 794 | case 0: |
| 795 | close(iofd); | 795 | close(iofd); |
| 796 | close(m); | ||
| 796 | setsid(); /* create a new process group */ | 797 | setsid(); /* create a new process group */ |
| 797 | dup2(s, 0); | 798 | dup2(s, 0); |
| 798 | dup2(s, 1); | 799 | dup2(s, 1); |
| 799 | dup2(s, 2); | 800 | dup2(s, 2); |
| 800 | if (ioctl(s, TIOCSCTTY, NULL) < 0) | 801 | if (ioctl(s, TIOCSCTTY, NULL) < 0) |
| 801 | die("ioctl TIOCSCTTY failed: %s\n", strerror(errno)); | 802 | die("ioctl TIOCSCTTY failed: %s\n", strerror(errno)); |
| 802 | close(s); | 803 | if (s > 2) |
| 803 | close(m); | 804 | close(s); |
| 804 | #ifdef __OpenBSD__ | 805 | #ifdef __OpenBSD__ |
| 805 | if (pledge("stdio getpw proc exec", NULL) == -1) | 806 | if (pledge("stdio getpw proc exec", NULL) == -1) |
| 806 | die("pledge\n"); | 807 | die("pledge\n"); |
