1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

- close() did not reset the non-blocking file property, as it should

have. This only worked for files which were closed anyway, but not
  for the stdio streams. Fixed.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14803 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2005-01-14 08:36:54 +00:00
parent 23f70d0c53
commit d23f4318f9
2 changed files with 20 additions and 7 deletions

View File

@ -51,6 +51,11 @@
- Lost some more code that is not required for AmigaOS 4.x and can be - Lost some more code that is not required for AmigaOS 4.x and can be
handled conveniently through conditional compilation. handled conveniently through conditional compilation.
- close() did not reset the non-blocking file property, as it should
have. This only worked for files which were closed anyway, but not
for the stdio streams. Fixed.
c.lib 1.185 (2.1.2005) c.lib 1.185 (2.1.2005)

View File

@ -1,5 +1,5 @@
/* /*
* $Id: fcntl_close.c,v 1.5 2005-01-12 09:15:50 obarthel Exp $ * $Id: fcntl_close.c,v 1.6 2005-01-14 08:36:54 obarthel Exp $
* *
* :ts=4 * :ts=4
* *
@ -45,9 +45,12 @@ int
__close(int file_descriptor,int * error_ptr) __close(int file_descriptor,int * error_ptr)
{ {
DECLARE_UTILITYBASE(); DECLARE_UTILITYBASE();
struct file_hook_message message;
struct fd * fd; struct fd * fd;
int result = -1; int result = -1;
BOOL no_close; BOOL no_close;
BOOL is_alias;
ENTER(); ENTER();
@ -96,6 +99,7 @@ __close(int file_descriptor,int * error_ptr)
} }
no_close = TRUE; no_close = TRUE;
is_alias = TRUE;
} }
else if (fd->fd_NextLink != NULL) /* this one has aliases attached; it is the 'original' resource */ else if (fd->fd_NextLink != NULL) /* this one has aliases attached; it is the 'original' resource */
{ {
@ -117,19 +121,18 @@ __close(int file_descriptor,int * error_ptr)
} }
no_close = TRUE; no_close = TRUE;
is_alias = TRUE;
} }
else else
{ {
no_close = FLAG_IS_SET(fd->fd_Flags,FDF_NO_CLOSE); no_close = FLAG_IS_SET(fd->fd_Flags,FDF_NO_CLOSE);
is_alias = FALSE;
} }
(*error_ptr) = OK; /* Reset the console to regular buffered/unbuffered input. We don't do this
for aliases and their like since the original stream is still in use. */
if(NOT no_close) if(NOT is_alias)
{ {
struct file_hook_message message;
/* Reset the console to regular buffered/unbuffered input. */
if((FLAG_IS_SET(fd->fd_Flags,FDF_NON_BLOCKING) && FLAG_IS_CLEAR(fd->fd_Flags,FDF_DEFAULT_NON_BLOCKING)) || if((FLAG_IS_SET(fd->fd_Flags,FDF_NON_BLOCKING) && FLAG_IS_CLEAR(fd->fd_Flags,FDF_DEFAULT_NON_BLOCKING)) ||
(FLAG_IS_CLEAR(fd->fd_Flags,FDF_NON_BLOCKING) && FLAG_IS_SET(fd->fd_Flags,FDF_DEFAULT_NON_BLOCKING))) (FLAG_IS_CLEAR(fd->fd_Flags,FDF_NON_BLOCKING) && FLAG_IS_SET(fd->fd_Flags,FDF_DEFAULT_NON_BLOCKING)))
{ {
@ -142,7 +145,12 @@ __close(int file_descriptor,int * error_ptr)
CallHookPkt(fd->fd_Hook,fd,&message); CallHookPkt(fd->fd_Hook,fd,&message);
} }
}
(*error_ptr) = OK;
if(NOT no_close && NOT is_alias)
{
SHOWMSG("shutting down"); SHOWMSG("shutting down");
message.action = file_hook_action_close; message.action = file_hook_action_close;