@@ -497,32 +497,6 @@ static void internal_exec_helper(parser_t &parser,
497
497
is_block=is_block_old;
498
498
}
499
499
500
- /* * Perform output from builtins. Called from a forked child, so don't do anything that may allocate memory, etc.. */
501
- static void do_builtin_io (const char *out, size_t outlen, const char *err, size_t errlen)
502
- {
503
- if (out && outlen)
504
- {
505
-
506
- if (write_loop (STDOUT_FILENO, out, outlen) == -1 )
507
- {
508
- debug (0 , L" Error while writing to stdout" );
509
- wperror (L" write_loop" );
510
- show_stackframe ();
511
- }
512
- }
513
-
514
- if (err && errlen)
515
- {
516
- if (write_loop (STDERR_FILENO, err, errlen) == -1 )
517
- {
518
- /*
519
- Can't really show any error message here, since stderr is
520
- dead.
521
- */
522
- }
523
- }
524
- }
525
-
526
500
/* Returns whether we can use posix spawn for a given process in a given job.
527
501
Per https://github.com/fish-shell/fish-shell/issues/364 , error handling for file redirections is too difficult with posix_spawn
528
502
So in that case we use fork/exec
@@ -1177,7 +1151,11 @@ void exec(parser_t &parser, job_t *j)
1177
1151
const wcstring &out = get_stdout_buffer (), &err = get_stderr_buffer ();
1178
1152
const std::string outbuff = wcs2string (out);
1179
1153
const std::string errbuff = wcs2string (err);
1180
- do_builtin_io (outbuff.data (), outbuff.size (), errbuff.data (), errbuff.size ());
1154
+ bool builtin_io_done = do_builtin_io (outbuff.data (), outbuff.size (), errbuff.data (), errbuff.size ());
1155
+ if (! builtin_io_done)
1156
+ {
1157
+ show_stackframe ();
1158
+ }
1181
1159
skip_fork = true ;
1182
1160
}
1183
1161
@@ -1239,7 +1217,6 @@ void exec(parser_t &parser, job_t *j)
1239
1217
setup_child_process (j, p);
1240
1218
do_builtin_io (outbuff, outbuff_len, errbuff, errbuff_len);
1241
1219
exit_without_destructors (p->status );
1242
-
1243
1220
}
1244
1221
else
1245
1222
{
0 commit comments