From: pseudo Date: Thu, 4 Aug 2022 01:45:09 +0000 (+0000) Subject: pty.c: Fix errant use of fcntl F_SETFD (#951) X-Git-Url: http://git.prime8.dev/?a=commitdiff_plain;h=1be5f5c0637f33a1b31e91d9dcc98cd3de17d657;p=ttyd.git pty.c: Fix errant use of fcntl F_SETFD (#951) * pty.c: Fix errant use of fcntl F_SETFL When this was added in https://github.com/tsl0922/ttyd/commit/cfd338ea5e1a3c3023acade45980b3024c41e507 We before this time the *File descriptor flags* (`F_GETFD`/`F_SETFD`) were augmented to include `FD_CLOEXEC` Then at this time the additional code added the *File status flags* (`F_GETFL`/`F_SETFL`) to include `O_NONBLOCK`, but this was weaved through code working with `F_SETFD` instead of `F_SETFL`. Some systems may use one big status word for all of them. Mine certainly dont. FIXES #733 --- diff --git a/src/pty.c b/src/pty.c index e5d47ed..b046a6a 100644 --- a/src/pty.c +++ b/src/pty.c @@ -470,7 +470,7 @@ int pty_spawn(pty_process *process, pty_read_cb read_cb, pty_exit_cb exit_cb) { status = -errno; goto error; } - if (fcntl(master, F_SETFD, flags | O_NONBLOCK) == -1) { + if (fcntl(master, F_SETFL, flags | O_NONBLOCK) == -1) { status = -errno; goto error; } @@ -502,4 +502,4 @@ error: waitpid(pid, NULL, 0); return status; } -#endif \ No newline at end of file +#endif