mirror of
https://github.com/tsl0922/ttyd.git
synced 2026-01-21 18:24:23 +01:00
terminal: set the pty fd non blocking
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#ifdef __linux__
|
||||
@@ -85,6 +86,14 @@ get_sig(const char *sig_name) {
|
||||
return atoi(sig_name);
|
||||
}
|
||||
|
||||
bool
|
||||
fd_set_cloexec(const int fd) {
|
||||
int flags = fcntl(fd, F_GETFD);
|
||||
if (flags < 0)
|
||||
return false;
|
||||
return (flags & FD_CLOEXEC) == 0 || fcntl(fd, F_SETFD, flags | FD_CLOEXEC) != -1;
|
||||
}
|
||||
|
||||
int
|
||||
wait_proc(pid_t in, pid_t *out) {
|
||||
int stat = 0, pid;
|
||||
|
||||
Reference in New Issue
Block a user