Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use of setjmp and longjmp 1

Status
Not open for further replies.
Jul 24, 1998
2
US
Can anyone provide an intro to gotchas of using setjmp and longjmp? My office mate is querying a temperature device on a serial port that may or may not respond and will put in a setjmp before the query but so far it isn't working. We're running Solaris 2.6 on Sun Ultra 10s, using Solaris' ProWorks C compiler.
 
To CaptainCrunch:



I would suggest you look into the acquisition of 'C Language Programming' by K&R to solve your setjmp/longjmp problem.
 
Not sure why you'd need to setjmp - can't you read/write (using nowait) the device file associated with the serial port to get the status?<br>
<br>
Mike
 
Actually setjmp(saves the current state of the program) and longjmp (Restores stack environment and execution locale) works in the way : <br>
<br>
If (a) then <br>
----<br>
else<br>
----<br>
endif.<br>
<br>
Now if you put setjump() in if part. and according to your logic the flow goes in else part. Now if you don't want to proceed in else part after some step. then these function will take you to the if part. All you neet to put these functions at the appropriate place.<br>
<br>
Does it answer your question ?<br>
Thanx,<br>
Siddhartha Singh<br>
<A HREF="mailto:ssingh@aztecsoft.com">ssingh@aztecsoft.com</A>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top