mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- Whether or not stdio console streams are blocking or non-blocking
is now determined at initialization time. The I/O mode is restored before the program exits. Previously, any changes to the I/O mode would persist. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14801 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@ -44,6 +44,10 @@
|
||||
out whether read/write accesses are permitted. This decision is now
|
||||
for the file system to make.
|
||||
|
||||
- Whether or not stdio console streams are blocking or non-blocking
|
||||
is now determined at initialization time. The I/O mode is restored before
|
||||
the program exits. Previously, any changes to the I/O mode would persist.
|
||||
|
||||
|
||||
c.lib 1.185 (2.1.2005)
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: fcntl_close.c,v 1.4 2005-01-02 09:07:07 obarthel Exp $
|
||||
* $Id: fcntl_close.c,v 1.5 2005-01-12 09:15:50 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -129,13 +129,14 @@ __close(int file_descriptor,int * error_ptr)
|
||||
{
|
||||
struct file_hook_message message;
|
||||
|
||||
/* Reset the console to regular buffered input. */
|
||||
if(FLAG_IS_SET(fd->fd_Flags,FDF_NON_BLOCKING))
|
||||
/* 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)) ||
|
||||
(FLAG_IS_CLEAR(fd->fd_Flags,FDF_NON_BLOCKING) && FLAG_IS_SET(fd->fd_Flags,FDF_DEFAULT_NON_BLOCKING)))
|
||||
{
|
||||
SHOWMSG("resetting non-blocking access mode");
|
||||
|
||||
message.action = file_hook_action_set_blocking;
|
||||
message.arg = 1;
|
||||
message.arg = FLAG_IS_SET(fd->fd_Flags,FDF_NON_BLOCKING);
|
||||
|
||||
assert( fd->fd_Hook != NULL );
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: macros.h,v 1.4 2005-01-02 09:07:07 obarthel Exp $
|
||||
* $Id: macros.h,v 1.5 2005-01-12 09:15:50 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -64,6 +64,10 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#define MILLION (1000000)
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#define NUM_ENTRIES(t) (sizeof(t) / sizeof(t[0]))
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_fdhookentry.c,v 1.6 2005-01-09 15:58:02 obarthel Exp $
|
||||
* $Id: stdio_fdhookentry.c,v 1.7 2005-01-12 09:15:50 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -1848,9 +1848,9 @@ __fd_hook_entry(
|
||||
SHOWMSG("changing the mode");
|
||||
|
||||
if(message->arg != 0)
|
||||
mode = 0; /* buffered mode */
|
||||
mode = DOSFALSE; /* buffered mode */
|
||||
else
|
||||
mode = 1; /* single character mode */
|
||||
mode = DOSTRUE; /* single character mode */
|
||||
|
||||
if(CANNOT SetMode(fd->fd_DefaultFile,mode))
|
||||
{
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_headers.h,v 1.8 2005-01-02 09:07:08 obarthel Exp $
|
||||
* $Id: stdio_headers.h,v 1.9 2005-01-12 09:15:50 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -249,25 +249,27 @@ struct iob
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#define FDF_READ (1UL<<0) /* Data can be read from this file */
|
||||
#define FDF_WRITE (1UL<<1) /* Data can be written to this file */
|
||||
#define FDF_APPEND (1UL<<2) /* Before any data is written to it,
|
||||
the file position must be set to the
|
||||
end of the file */
|
||||
#define FDF_NO_CLOSE (1UL<<3) /* Never close this file */
|
||||
#define FDF_NON_BLOCKING (1UL<<4) /* File was switched into non-blocking
|
||||
mode (console streams only) */
|
||||
#define FDF_IS_SOCKET (1UL<<5) /* This is not a disk file but a socket */
|
||||
#define FDF_IS_LOCKED (1UL<<6) /* This file has an advisory record lock set */
|
||||
#define FDF_IN_USE (1UL<<7) /* This file is in use */
|
||||
#define FDF_CREATED (1UL<<8) /* This file was newly created and may need
|
||||
to have its protection bits updated after
|
||||
it has been closed */
|
||||
#define FDF_CACHE_POSITION (1UL<<9) /* Cache the file position. */
|
||||
#define FDF_ASYNC_IO (1UL<<10) /* File was switched into asynchronous I/O
|
||||
mode (sockets only). */
|
||||
#define FDF_IS_INTERACTIVE (1UL<<11) /* File is attached to a console window or
|
||||
something like it. */
|
||||
#define FDF_READ (1UL<<0) /* Data can be read from this file */
|
||||
#define FDF_WRITE (1UL<<1) /* Data can be written to this file */
|
||||
#define FDF_APPEND (1UL<<2) /* Before any data is written to it,
|
||||
the file position must be set to the
|
||||
end of the file */
|
||||
#define FDF_NO_CLOSE (1UL<<3) /* Never close this file */
|
||||
#define FDF_NON_BLOCKING (1UL<<4) /* File was switched into non-blocking
|
||||
mode (console streams only) */
|
||||
#define FDF_IS_SOCKET (1UL<<5) /* This is not a disk file but a socket */
|
||||
#define FDF_IS_LOCKED (1UL<<6) /* This file has an advisory record lock set */
|
||||
#define FDF_IN_USE (1UL<<7) /* This file is in use */
|
||||
#define FDF_CREATED (1UL<<8) /* This file was newly created and may need
|
||||
to have its protection bits updated after
|
||||
it has been closed */
|
||||
#define FDF_CACHE_POSITION (1UL<<9) /* Cache the file position. */
|
||||
#define FDF_ASYNC_IO (1UL<<10) /* File was switched into asynchronous I/O
|
||||
mode (sockets only). */
|
||||
#define FDF_IS_INTERACTIVE (1UL<<11) /* File is attached to a console window or
|
||||
something like it. */
|
||||
#define FDF_DEFAULT_NON_BLOCKING (1UL<<12) /* This file defaults to non-blocking I/O
|
||||
mode. */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_init_exit.c,v 1.11 2005-01-09 15:58:02 obarthel Exp $
|
||||
* $Id: stdio_init_exit.c,v 1.12 2005-01-12 09:15:50 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -188,8 +188,29 @@ __stdio_init(void)
|
||||
PROFILE_OFF();
|
||||
|
||||
if(IsInteractive(default_file))
|
||||
{
|
||||
struct FileHandle * fh;
|
||||
|
||||
SET_FLAG(fd_flags,FDF_IS_INTERACTIVE);
|
||||
|
||||
/* Try to figure out if the console is in single
|
||||
character mode. */
|
||||
fh = BADDR(default_file);
|
||||
if(fh->fh_Type != NULL)
|
||||
{
|
||||
D_S(struct InfoData,id);
|
||||
|
||||
if(DoPkt(fh->fh_Type,ACTION_DISK_INFO,MKBADDR(id),0,0,0,0))
|
||||
{
|
||||
if(id->id_DiskType == ID_RAWCON)
|
||||
{
|
||||
SET_FLAG(fd_flags,FDF_NON_BLOCKING);
|
||||
SET_FLAG(fd_flags,FDF_DEFAULT_NON_BLOCKING);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PROFILE_ON();
|
||||
}
|
||||
|
||||
@ -254,7 +275,26 @@ __stdio_init(void)
|
||||
if(__fd[STDERR_FILENO]->fd_DefaultFile != ZERO)
|
||||
{
|
||||
if(IsInteractive(__fd[STDERR_FILENO]->fd_DefaultFile))
|
||||
{
|
||||
struct FileHandle * fh;
|
||||
|
||||
SET_FLAG(__fd[STDERR_FILENO]->fd_Flags,FDF_IS_INTERACTIVE);
|
||||
|
||||
fh = BADDR(__fd[STDERR_FILENO]->fd_DefaultFile);
|
||||
if(fh->fh_Type != NULL)
|
||||
{
|
||||
D_S(struct InfoData,id);
|
||||
|
||||
if(DoPkt(fh->fh_Type,ACTION_DISK_INFO,MKBADDR(id),0,0,0,0))
|
||||
{
|
||||
if(id->id_DiskType == ID_RAWCON)
|
||||
{
|
||||
SET_FLAG(__fd[STDERR_FILENO]->fd_Flags,FDF_NON_BLOCKING);
|
||||
SET_FLAG(__fd[STDERR_FILENO]->fd_Flags,FDF_DEFAULT_NON_BLOCKING);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PROFILE_ON();
|
||||
|
||||
Reference in New Issue
Block a user