vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Is there exception handling in AIX/Unix/Linux similar to how exceptions are handled in C++? I have a unix programming book by Stevens and a couple of Perl books just arrived and I dont see any mention of throwing and catching exceptions. ( I just read about die, the non zero return value standard and stderr ) An example might be a socket connection to a remote system. I always want that connection to shutdown in a way the remote system expects. Will a Perl script be able to catch all the potential dieing that could happen in the process and send a nice disconnect message to the remote system? thanks, -Steve |
| |||
| StephenRichter@gmail.com writes: > Is there exception handling in AIX/Unix/Linux similar to how exceptions > are handled in C++? In what language? Yes, in C++. > I have a unix programming book by Stevens and a > couple of Perl books just arrived and I dont see any mention of > throwing and catching exceptions. Stevens book is all in C, and there is no structured exception handling in that language. > ( I just read about die, the non zero > return value standard and stderr ) In Perl, you could 'catch' exceptions like this: eval "some code which might die"; if ($@) { # did die ... > An example might be a socket connection to a remote system. I always > want that connection to shutdown in a way the remote system expects. > Will a Perl script be able to catch all the potential dieing that could > happen in the process and send a nice disconnect message to the remote > system? Sure. However, if remote requires a nice disconnect, it is broken: think what would happen if you cut the network cable from local host (while the app is running), then reboot it and plug it back in. Cheers, -- In order to understand recursion you must first understand recursion. Remove /-nsp/ for email. |
| |||
| Paul Pluzhnikov wrote: > StephenRichter@gmail.com writes: > > > Is there exception handling in AIX/Unix/Linux similar to how exceptions > > are handled in C++? > > In what language? Yes, in C++. > > > I have a unix programming book by Stevens and a > > couple of Perl books just arrived and I dont see any mention of > > throwing and catching exceptions. > > Stevens book is all in C, and there is no structured exception > handling in that language. Does Unix itself have a call stack and a facility for unwinding that stack when an exception is thrown? Windows for example uses structured exception handling that embeds exception handling entries in the call stack of a thread. On the system I am migrating from, the as400, an exception is thrown by sending an *escape message from one level of the call stack to a prior level. -Steve |
| ||||
| StephenRichter@gmail.com writes: > Does Unix itself have There is no such thing as "UNIX itself". There are Linux Fedora Core 2, Red Hat Enterprise Server 4.0, Solaris 10 update 1, AIX 5.3, etc. etc. > a call stack Every computer that is capable of running UNIX has a "call stack". Some processors have special "call stack" instructions, others "emulate" it, using "regular" registers and "normal" load/store instructions, etc. > and a facility for unwinding that > stack when an exception is thrown? What does "when exception is thrown" mean in a language that doesn't support exceptions (such as C)? Some system libraries (e.g. glibc on x86) support unwinding stack, provided the code has not been compiled in a way making such unwinding impossible (e.g. 'gcc -O3 -fomit-frame-pointer ...'). > Windows for example uses structured > exception handling that embeds exception handling entries in the call > stack of a thread. "Windows" doesn't do that. One particular compiler: "MicroSoft Visual C" has an extension which allows programmer to easily embed such entries. Windows also has a system library (KERNEL32.DLL IIRC) which knows how to find such entries, and how to "do the right thing" when an exception is thrown by KERNEL32.DLL RaiseException() call. > On the system I am migrating from, the as400, I've never worked on one of these, and claim absolute zero knowledge. > exception is thrown by sending an *escape message from one level of the > call stack to a prior level. There are languages (C++, Perl, Python, etc.) that support this concept, and there are library implementations which allow one to unwind call stack, but there is no "general exception facility" on UNIX that's applicable to all UNIXes and all languages. Cheers, -- In order to understand recursion you must first understand recursion. Remove /-nsp/ for email. |