mirror of
https://github.com/tsl0922/ttyd.git
synced 2026-01-07 03:14:22 +01:00
server: improve child process handling
This commit is contained in:
18
src/utils.c
18
src/utils.c
@@ -4,9 +4,7 @@
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#ifdef __linux__
|
||||
// https://github.com/karelzak/util-linux/blob/master/misc-utils/kill.c
|
||||
@@ -94,22 +92,6 @@ fd_set_cloexec(const int fd) {
|
||||
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;
|
||||
do {
|
||||
pid = waitpid(in, &stat, WNOHANG);
|
||||
} while (pid < 0 && errno == EINTR);
|
||||
if (out != NULL) *out = pid;
|
||||
int status = -1;
|
||||
if (WIFEXITED(stat)) {
|
||||
status = WEXITSTATUS(stat);
|
||||
} else if (WIFSIGNALED(stat)) {
|
||||
status = WTERMSIG(stat);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
int
|
||||
open_uri(char *uri) {
|
||||
#ifdef __APPLE__
|
||||
|
||||
Reference in New Issue
Block a user