File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -211,6 +211,7 @@ static void dumpBacktrace( unsigned int depth )
211
211
depth = 20 ;
212
212
213
213
#if (defined(linux) && !defined(ANDROID)) || defined(__FreeBSD__)
214
+ int stderr_fd = -1 ;
214
215
if ( access ( " /usr/bin/c++filt" , X_OK ) < 0 )
215
216
{
216
217
myPrint ( " Stacktrace (c++filt NOT FOUND):\n " );
@@ -230,15 +231,25 @@ static void dumpBacktrace( unsigned int depth )
230
231
}
231
232
232
233
myPrint ( " Stacktrace (piped through c++filt):\n " );
234
+ stderr_fd = dup ( STDERR_FILENO );
233
235
close ( fd[0 ] ); // close reading end
234
236
close ( STDERR_FILENO ); // close stderr
235
237
dup ( fd[1 ] ); // stderr to pipe
238
+ close ( fd[1 ] ); // close duped pipe
236
239
}
237
240
238
241
void **buffer = new void *[ depth ];
239
242
int nptrs = backtrace ( buffer, depth );
240
243
backtrace_symbols_fd ( buffer, nptrs, STDERR_FILENO );
241
244
delete [] buffer;
245
+ if ( stderr_fd >= 0 )
246
+ {
247
+ int status;
248
+ close ( STDERR_FILENO );
249
+ dup ( stderr_fd );
250
+ close ( stderr_fd );
251
+ wait ( &status );
252
+ }
242
253
#elif defined(Q_OS_WIN)
243
254
void **buffer = new void *[ depth ];
244
255
You can’t perform that action at this time.
0 commit comments