Skip to content
Snippets Groups Projects
Commit d3ef71cb authored by Fredrik Hübinette (Hubbe)'s avatar Fredrik Hübinette (Hubbe)
Browse files

fixed to check more for EINTR

Rev: src/modules/files/file.c:1.3
Rev: src/modules/files/socket.c:1.2
parent e2712ad1
Branches
Tags
No related merge requests found
...@@ -76,7 +76,20 @@ static int close_fd(int fd) ...@@ -76,7 +76,20 @@ static int close_fd(int fd)
{ {
return 0; return 0;
}else{ }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) ...@@ -408,6 +421,7 @@ static void file_open(INT32 args)
THIS->errno = 0; THIS->errno = 0;
retry:
fd=open(sp[-args].u.string->str,map(flags), 00666); fd=open(sp[-args].u.string->str,map(flags), 00666);
if(fd >= MAX_OPEN_FILEDESCRIPTORS) if(fd >= MAX_OPEN_FILEDESCRIPTORS)
...@@ -418,6 +432,9 @@ static void file_open(INT32 args) ...@@ -418,6 +432,9 @@ static void file_open(INT32 args)
} }
else if(fd < 0) else if(fd < 0)
{ {
if(errno == EINTR)
goto retry;
THIS->errno=errno; THIS->errno=errno;
} }
else else
...@@ -482,8 +499,10 @@ static void file_stat(INT32 args) ...@@ -482,8 +499,10 @@ static void file_stat(INT32 args)
pop_n_elems(args); pop_n_elems(args);
retry:
if(fstat(THIS->fd, &s) < 0) if(fstat(THIS->fd, &s) < 0)
{ {
if(errno == EINTR) goto retry;
THIS->errno=errno; THIS->errno=errno;
push_int(0); push_int(0);
}else{ }else{
...@@ -1145,22 +1164,6 @@ void exit_files() ...@@ -1145,22 +1164,6 @@ void exit_files()
free_program(file_program); 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() void init_files_programs()
{ {
...@@ -1175,9 +1178,6 @@ void init_files_programs() ...@@ -1175,9 +1178,6 @@ void init_files_programs()
reference_fd(1); reference_fd(1);
reference_fd(2); reference_fd(2);
signal(SIGCHLD,sig_child);
signal(SIGPIPE,SIG_IGN);
start_new_program(); start_new_program();
add_storage(sizeof(struct file)); add_storage(sizeof(struct file));
......
...@@ -56,9 +56,13 @@ struct port ...@@ -56,9 +56,13 @@ struct port
static void do_close(struct port *p) static void do_close(struct port *p)
{ {
retry:
if(p->fd >= 0) if(p->fd >= 0)
{ {
close(p->fd); if(close(p->fd) < 0)
if(errno == RETRY)
goto retry;
set_read_callback(p->fd,0,0); set_read_callback(p->fd,0,0);
} }
...@@ -186,7 +190,6 @@ static void port_bind(INT32 args) ...@@ -186,7 +190,6 @@ static void port_bind(INT32 args)
set_close_on_exec(fd,1); set_close_on_exec(fd,1);
if(args > 2 && sp[2-args].type==T_STRING) if(args > 2 && sp[2-args].type==T_STRING)
{ {
get_inet_addr(&addr, sp[2-args].u.string->str); get_inet_addr(&addr, sp[2-args].u.string->str);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment