From d3ef71cb23d74fc6520a2eceb7194e32d6fb8baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Thu, 2 Nov 1995 00:16:13 +0100 Subject: [PATCH] fixed to check more for EINTR Rev: src/modules/files/file.c:1.3 Rev: src/modules/files/socket.c:1.2 --- src/modules/files/file.c | 40 +++++++++++++++++++------------------- src/modules/files/socket.c | 7 +++++-- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/modules/files/file.c b/src/modules/files/file.c index 2d08ecc940..80b31f745d 100644 --- a/src/modules/files/file.c +++ b/src/modules/files/file.c @@ -76,7 +76,20 @@ static int close_fd(int fd) { return 0; }else{ - return close(fd); + while(1) + { + if(close(fd) >= 0) return 0; + switch(errno) + { + default: + fatal("Unknown error in close().\n"); + + case EBADF: + fatal("Closing a non-active file descriptor.\n"); + + case EINTR: + } + } } } @@ -408,6 +421,7 @@ static void file_open(INT32 args) THIS->errno = 0; + retry: fd=open(sp[-args].u.string->str,map(flags), 00666); if(fd >= MAX_OPEN_FILEDESCRIPTORS) @@ -418,6 +432,9 @@ static void file_open(INT32 args) } else if(fd < 0) { + if(errno == EINTR) + goto retry; + THIS->errno=errno; } else @@ -482,8 +499,10 @@ static void file_stat(INT32 args) pop_n_elems(args); + retry: if(fstat(THIS->fd, &s) < 0) { + if(errno == EINTR) goto retry; THIS->errno=errno; push_int(0); }else{ @@ -1145,22 +1164,6 @@ void exit_files() free_program(file_program); } -static RETSIGTYPE sig_child(int arg) -{ -#ifdef HAVE_WAITPID - waitpid(-1,0,WNOHANG); - signal(SIGCHLD,sig_child); -#else -#ifdef HAVE_WAIT3 - wait3(-1,0,WNOHANG); - signal(SIGCHLD,sig_child); -#else - - /* Leave'em hanging */ - -#endif /* HAVE_WAIT3 */ -#endif /* HAVE_WAITPID */ -} void init_files_programs() { @@ -1175,9 +1178,6 @@ void init_files_programs() reference_fd(1); reference_fd(2); - signal(SIGCHLD,sig_child); - signal(SIGPIPE,SIG_IGN); - start_new_program(); add_storage(sizeof(struct file)); diff --git a/src/modules/files/socket.c b/src/modules/files/socket.c index a71c86886b..8a94fa17c5 100644 --- a/src/modules/files/socket.c +++ b/src/modules/files/socket.c @@ -56,9 +56,13 @@ struct port static void do_close(struct port *p) { + retry: if(p->fd >= 0) { - close(p->fd); + if(close(p->fd) < 0) + if(errno == RETRY) + goto retry; + set_read_callback(p->fd,0,0); } @@ -186,7 +190,6 @@ static void port_bind(INT32 args) set_close_on_exec(fd,1); - if(args > 2 && sp[2-args].type==T_STRING) { get_inet_addr(&addr, sp[2-args].u.string->str); -- GitLab