Run a program transparently, but print a stack trace if it fails

gdb -batch -ex "run" -ex "bt" ${my_program} 2>&1 | grep -v ^"No stack."$
For automated unit tests I wanted my program to run normally, but if it crashed, to add a stack trace to the output log. I came up with this command so I wouldn't have to mess around with core files. The one downside is that it does smoosh your program's stderr and stdout together.
Sample Output
Should be identical to what ${my_program} normally generates, unless ${my_program} crashes, in which case it ends with a stack trace.

By: kurt
2010-12-29 17:46:31

2 Alternatives + Submit Alt

What Others Think

Running this program smoothly as they are dealing with the best so far. I am grateful to this blog for sharing this program with us. I am looking forward to such kind of many programs to be offered by them in such a positive way and go to CocoFinder site to check imei tracking number and locate cell phone. So try to learn how to run them smoothly.
MaryKlein · 36 weeks and 3 days ago
Thank you very much for the sharing! COOL.. best restaurant cozumel
xoheko1229 · 29 weeks and 2 days ago
Very nice article, I enjoyed reading your post, very nice share, I want to twit this to my followers. Thanks!. cozumel dive resort
xoheko1229 · 29 weeks and 1 day ago
I have been checking out a few of your stories and i can state pretty good stuff. I will definitely bookmark your blog best beach hotel in cancun
xoheko1229 · 28 weeks and 3 days ago
I felt very happy while reading this site. This was really very informative site for me. I really liked it. This was really a cordial post. Thanks a lot!. best restaurant in playa del carmen mexico
xoheko1229 · 28 weeks and 1 day ago
Impressive web site, Distinguished feedback that I can tackle. I am moving forward and may apply to my current job as a pet sitter, which is very enjoyable, but I need to additional expand. Regards. isla mujeres beaches
xoheko1229 · 28 weeks and 1 day ago
This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value. Im glad to have found this post as its such an interesting one! I am always on the lookout for quality posts and articles so i suppose im lucky to have found this! I hope you will be adding more in the future... all inclusive resorts in isla mujeres mexico
xoheko1229 · 27 weeks and 6 days ago
I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post. how to get to isla contoy
xoheko1229 · 27 weeks and 5 days ago
Thanks so much for this incredible resource. roofers Chula Vista
JayMRG · 26 weeks and 1 day ago
Thank you for sharing this amazing post. keep up the great work pool cleaners services
thamus · 22 weeks and 2 days ago
This is so impressive! thank so much geometry dash
chanlisa · 22 weeks and 1 day ago
i am reading this enormous educational paragraph here at my house. basil leaves in hindi
fopeez · 8 weeks ago
Hey there just wanted to give you a quick heads up. basil in hindi ego meaning in hindi
fopeez · 6 weeks and 2 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: