mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-25 04:22:04 +08:00
Check error code when writing output from builtins - try to report errors
darcs-hash:20070121145810-ac50b-46ecb601ce9f0d862f00e4a97f25b6034e52f4cc.gz
This commit is contained in:
parent
64f1024eb5
commit
a1ec38f53b
33
exec.c
33
exec.c
@ -762,6 +762,34 @@ static pid_t exec_fork()
|
||||
}
|
||||
|
||||
|
||||
static void do_builtin_io( wchar_t *out, wchar_t *err )
|
||||
{
|
||||
|
||||
if( out )
|
||||
{
|
||||
if( fwprintf( stdout, L"%ls", out ) == -1 || fflush( stdout ) == EOF )
|
||||
{
|
||||
debug( 0, L"Error while writing to stdout" );
|
||||
wperror( L"fwprintf" );
|
||||
show_stackframe();
|
||||
}
|
||||
}
|
||||
|
||||
if( err )
|
||||
{
|
||||
if( fwprintf( stderr, L"%ls", err ) == -1 || fflush( stderr ) == EOF )
|
||||
{
|
||||
/*
|
||||
Can't really show any error message here, since stderr is
|
||||
dead. Complain a bit on stdout.
|
||||
*/
|
||||
fwprintf( stdout, L"fish: Error while writing to stderr\n" );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void exec( job_t *j )
|
||||
{
|
||||
process_t *p;
|
||||
@ -1351,10 +1379,7 @@ void exec( job_t *j )
|
||||
|
||||
p->pid = getpid();
|
||||
setup_child_process( j, p );
|
||||
if( sb_out->used )
|
||||
fwprintf( stdout, L"%ls", sb_out->buff );
|
||||
if( sb_err->used )
|
||||
fwprintf( stderr, L"%ls", sb_err->buff );
|
||||
do_builtin_io( sb_out->used ? (wchar_t *)sb_out->buff : 0, sb_err->used ? (wchar_t *)sb_err->buff : 0 );
|
||||
|
||||
exit( p->status );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user