- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- What does the setjmp function do?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2006 07:47 AM
08-14-2006 07:47 AM
I am trying to maintain some very old C code and I am very confused. The source looks something like this:
if (setjmp(jump)) != 0) {
recover();
warning("Task not completed!");
}
process_command();
I have read the man page and it just doesn't make sense! I have found that when Control-C is pressed that I do see the "Task not completed!" message but nothing about this makes any sense to me.
Any ideas?
TIA,
David
Solved! Go to Solution.
- Tags:
- setjmp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2006 08:12 AM
08-14-2006 08:12 AM
SolutionYou were probably taught that goto's are bad; well setjmp/longjmp allow you to do goto's even outside the current function (or even outside the source file that contains the setjmp). If local goto's are bad then non-local goto's must be superbad -- but that doesn't mean that they aren't sometimes useful.
- Tags:
- longjmp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2006 08:20 AM
08-14-2006 08:20 AM
Re: What does the setjmp function do?
Read the setjmp man page again and it should make a little more sense now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2006 09:29 AM
08-14-2006 09:29 AM
Re: What does the setjmp function do?
Oh, and to make the ghost of Edsger Dijkstra really mad, I intention put in a local goto as well as the non-local setjmp/longjmp goto.
Compile the attached code like this:
cc setjmp.c -o setjmp and then simply execute "setjmp".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2006 09:29 AM
08-14-2006 09:29 AM
Re: What does the setjmp function do?
Oh, and to make the ghost of Edsger Dijkstra really mad, I intention put in a local goto as well as the non-local setjmp/longjmp goto.
Compile the attached code like this:
cc setjmp.c -o setjmp and then simply execute "setjmp".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2006 09:53 AM
08-14-2006 09:53 AM
Re: What does the setjmp function do?
Your example really helped! I think I at least understand the concept but I still haven't found the longjmp function in the source. I will continue to look for it.
Thanks,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2006 10:31 AM
08-14-2006 10:31 AM
Re: What does the setjmp function do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2006 05:54 PM
08-14-2006 05:54 PM
Re: What does the setjmp function do?
As Clay says, it could be anywhere.
But why not let the computer find it? Run your application in the debugger and set a breakpoint in longjmp. That will find the first use.
Note you don't need debug info, if you can find it after you know the function or shared lib names.