From 877996465a9ba2a9470ef9551e09072c39e93671 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Thu, 6 May 2021 14:04:07 +0100 Subject: [PATCH] LibC: Update forkpty() master fd before fork()'s child branch --- Userland/Libraries/LibC/pty.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibC/pty.cpp b/Userland/Libraries/LibC/pty.cpp index 0c72a31ef2..e514c60924 100644 --- a/Userland/Libraries/LibC/pty.cpp +++ b/Userland/Libraries/LibC/pty.cpp @@ -79,13 +79,13 @@ pid_t forkpty(int* amaster, char* name, const struct termios* termp, const struc close(slave); return -1; } + *amaster = master; if (pid == 0) { close(master); if (login_tty(slave) < 0) _exit(1); return 0; } - *amaster = master; close(slave); return pid; }