mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- Aliases of file descriptors are now using the signal semaphore
of the original file descriptor. - close() did not return 0 if the file descriptor in question was really just an alias. Fixed. - Added a feature which makes it possible to have several clients use the standard I/O streams (stdin/stdout/stderr) and have these referring to their process' Input()/Output()/ErrorOutput() streams. This is intended to support the upcoming shared library feature. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14885 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_fdhookentry.c,v 1.19 2005-03-09 12:06:10 obarthel Exp $
|
||||
* $Id: stdio_fdhookentry.c,v 1.20 2005-03-12 09:43:48 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -75,6 +75,35 @@ __fd_hook_entry(
|
||||
__fd_lock(fd);
|
||||
|
||||
file = fd->fd_DefaultFile;
|
||||
|
||||
/* Check if this file should be dynamically bound to one of the
|
||||
three standard I/O streams. */
|
||||
if(file == ZERO && FLAG_IS_SET(fd->fd_Flags,FDF_STDIO))
|
||||
{
|
||||
if (fd == __fd[STDIN_FILENO])
|
||||
{
|
||||
file = Input();
|
||||
}
|
||||
else if (fd == __fd[STDOUT_FILENO])
|
||||
{
|
||||
file = Output();
|
||||
}
|
||||
else if (fd == __fd[STDERR_FILENO])
|
||||
{
|
||||
#if defined(__amigaos4__)
|
||||
{
|
||||
file = ErrorOutput();
|
||||
}
|
||||
#else
|
||||
{
|
||||
struct Process * this_process = (struct Process *)FindTask(NULL);
|
||||
|
||||
file = this_process->pr_CES;
|
||||
}
|
||||
#endif /* __amigaos4__ */
|
||||
}
|
||||
}
|
||||
|
||||
if(file == ZERO)
|
||||
{
|
||||
SHOWMSG("file is closed");
|
||||
@ -160,23 +189,23 @@ __fd_hook_entry(
|
||||
|
||||
SHOWMSG("file_action_close");
|
||||
|
||||
/* The following is almost guaranteed not to fail. */
|
||||
result = 0;
|
||||
|
||||
/* If this is an alias, just remove it. */
|
||||
if(__fd_is_aliased(fd))
|
||||
{
|
||||
__remove_fd_alias(fd);
|
||||
}
|
||||
else
|
||||
else if (fd->fd_DefaultFile != ZERO)
|
||||
{
|
||||
/* The following is almost guaranteed not to fail. */
|
||||
result = 0;
|
||||
|
||||
/* Are we disallowed to close this file? */
|
||||
if(FLAG_IS_SET(fd->fd_Flags,FDF_NO_CLOSE))
|
||||
{
|
||||
/* OK, so we cannot close it. But we might be obliged to
|
||||
reset a console into buffered mode. */
|
||||
if(FLAG_IS_SET(fd->fd_Flags,FDF_NON_BLOCKING) && FLAG_IS_SET(fd->fd_Flags,FDF_IS_INTERACTIVE))
|
||||
SetMode(file,DOSFALSE);
|
||||
SetMode(fd->fd_DefaultFile,DOSFALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -194,14 +223,14 @@ __fd_hook_entry(
|
||||
|
||||
PROFILE_OFF();
|
||||
|
||||
parent_dir = __safe_parent_of_file_handle(file);
|
||||
parent_dir = __safe_parent_of_file_handle(fd->fd_DefaultFile);
|
||||
if(parent_dir != ZERO)
|
||||
{
|
||||
if(__safe_examine_file_handle(file,fib))
|
||||
if(__safe_examine_file_handle(fd->fd_DefaultFile,fib))
|
||||
name_and_path_valid = TRUE;
|
||||
}
|
||||
|
||||
if(CANNOT Close(file))
|
||||
if(CANNOT Close(fd->fd_DefaultFile))
|
||||
{
|
||||
fam->fam_Error = __translate_io_error_to_errno(IoErr());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user