mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- Added a wrapper function which handles the thread-safe stdio stream
resolution. - In tcflush() a break signal can no longer cause the read flush loop to be quit with two semaphores still locked. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15170 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: termios_tcdrain.c,v 1.3 2006-01-08 12:04:27 obarthel Exp $
|
||||
* $Id: termios_tcdrain.c,v 1.4 2006-11-16 14:39:23 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@@ -48,8 +48,6 @@ tcdrain(int file_descriptor)
|
||||
{
|
||||
int result = ERROR;
|
||||
struct fd *fd;
|
||||
struct termios *tios;
|
||||
BPTR file;
|
||||
|
||||
ENTER();
|
||||
|
||||
@@ -69,64 +67,18 @@ tcdrain(int file_descriptor)
|
||||
|
||||
__fd_lock(fd);
|
||||
|
||||
file = fd->fd_DefaultFile;
|
||||
|
||||
#if defined(__THREAD_SAFE)
|
||||
{
|
||||
if(FLAG_IS_SET(fd->fd_Flags,FDF_STDIO))
|
||||
{
|
||||
switch(fd->fd_DefaultFile)
|
||||
{
|
||||
case STDIN_FILENO:
|
||||
|
||||
file = Input();
|
||||
break;
|
||||
|
||||
case STDOUT_FILENO:
|
||||
|
||||
file = Output();
|
||||
break;
|
||||
|
||||
case STDERR_FILENO:
|
||||
|
||||
#if defined(__amigaos4__)
|
||||
{
|
||||
file = ErrorOutput();
|
||||
}
|
||||
#else
|
||||
{
|
||||
struct Process * this_process = (struct Process *)FindTask(NULL);
|
||||
|
||||
file = this_process->pr_CES;
|
||||
}
|
||||
#endif /* __amigaos4__ */
|
||||
|
||||
/* The following is rather controversial; if the standard error stream
|
||||
is unavailable, we default to reuse the standard output stream. This
|
||||
is problematic if the standard output stream was redirected and should
|
||||
not be the same as the standard error output stream. */
|
||||
if(file == ZERO)
|
||||
file = Output();
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
file = ZERO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* __THREAD_SAFE */
|
||||
|
||||
if(FLAG_IS_SET(fd->fd_Flags,FDF_TERMIOS))
|
||||
{
|
||||
struct termios *tios;
|
||||
BPTR file;
|
||||
|
||||
tios = fd->fd_Aux;
|
||||
|
||||
switch(tios->type)
|
||||
{
|
||||
case TIOST_CONSOLE:
|
||||
|
||||
file = __resolve_fd_file(fd);
|
||||
if(file == ZERO)
|
||||
{
|
||||
__set_errno(EBADF);
|
||||
|
||||
Reference in New Issue
Block a user