Re: [fpc-pascal] exitproc?
On Tue, August 5, 2014 02:00, waldo kitty wrote: back in the [g]?olden days of TP6, i used to be able to set an exitproc procedure that would be executed any time my program exited for any reason... something like exitproc := @myexitproc; is this still able to be done easily? does it work even if there's an untrapped exception? Yes. Yes, as long as the exception is handled (caught) by the RTL. Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] exitproc?
is this still able to be done easily? No difference I guess: http://www.freepascal.org/docs-html/rtl/system/exitproc.html However, this is better: http://www.freepascal.org/docs-html/rtl/system/addexitproc.html does it work even if there's an untrapped exception? Just try it -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/exitproc-tp5719871p5719877.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] exitproc?
On 8/5/2014 3:29 AM, Tomas Hajny wrote: On Tue, August 5, 2014 02:00, waldo kitty wrote: back in the [g]?olden days of TP6, i used to be able to set an exitproc procedure that would be executed any time my program exited for any reason... something like exitproc := @myexitproc; is this still able to be done easily? does it work even if there's an untrapped exception? Yes. Yes, as long as the exception is handled (caught) by the RTL. do you mean that it cannot be a unhandled exception with ''crash'' and heaptrace dumping the thousands of left-behind memory blocks that weren't deallocated?? that's what i'm trying to get past... i want to see the error and unhandled exceptions but i really want to properly deallocate the 4+ * 5 records on the heap instead of having to either wait for heaptrace to finish dumping them or forcibly closing the task or (in the worst cases) rebooting the entire machine... this is a console app based on tapplication (mainly for parameter parsing capability) and i have no clue (yet) how to catch exceptions and deal with them properly... additionally, this last time i had to deal with this, fpc 2.6.4 release for OS/2 was dieing with unknown error 110 (IIRC) during runtime... i finally determined this to be from trying to reset a file that didn't exist where the path was pointing to... goofy error on my part that i fixed by fsplitting the pattern and adding the directory portion back to the initial directory path being used... in any case, i thought i should also mention this so that it can be corrected so it is not unknown any more ;) -- NOTE: No off-list assistance is given without prior approval. Please *keep mailing list traffic on the list* unless private contact is specifically requested and granted. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] exitproc?
On 8/5/2014 12:51 PM, leledumbo wrote: is this still able to be done easily? No difference I guess: http://www.freepascal.org/docs-html/rtl/system/exitproc.html However, this is better: http://www.freepascal.org/docs-html/rtl/system/addexitproc.html thanks for the pointers! i was extremely tired when i wrote my original post... 16 hours editing (reformatting) a wikipedia table and researching the hundreds of entries in it can really make one's eyes cross :/ does it work even if there's an untrapped exception? Just try it i will try... hopefully i won't have to do anything to execute my existing procedures and i'll be able to stop manually executing them in my code as they should be executed automatically by using this method... -- NOTE: No off-list assistance is given without prior approval. Please *keep mailing list traffic on the list* unless private contact is specifically requested and granted. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] exitproc?
back in the [g]?olden days of TP6, i used to be able to set an exitproc procedure that would be executed any time my program exited for any reason... something like exitproc := @myexitproc; is this still able to be done easily? does it work even if there's an untrapped exception? -- NOTE: No off-list assistance is given without prior approval. Please *keep mailing list traffic on the list* unless private contact is specifically requested and granted. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] ExitProc
If I compile and run my example program and then press Crtl+C the program terminates. I would expect that it terminate by calling CloseServer procedure, but it dos not. If the program terminates normally (time runs out) the CloseServer procedure is called as expected. Have I misunderstood something about the ExitProc. Regards Carsten program exitp; Uses sysutils;{System} var ExitProcGem:pointer; Procedure CloseServer; Begin ExitProc:=ExitProcGem; WriteLn('Server closed.'); End; begin ExitProcGem:=ExitProc; ExitProc:[EMAIL PROTECTED]; sleep(1); WriteLn('--Close--'); end. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] ExitProc
On 29 jun 2006, at 13:51, Carsten Bager wrote: If I compile and run my example program and then press Crtl+C the program terminates. I would expect that it terminate by calling CloseServer procedure, but it dos not. If the program terminates normally (time runs out) the CloseServer procedure is called as expected. Have I misunderstood something about the ExitProc. ExitProc is only called if your program exits via the RTL. This is the case when the program exits normally, or when a run time error or unhandled exception occurs. ctrl-c is not caught by the FPC RTL. This means it is handled by the operating system, and the default action of the operating system is to simply terminate the process. The FPC RTL therefore does not get any chance to call your exitproc. I don't know whether there's a platform-independent way in the RTL to turn on the catching of ctrl-c (and converting it to an exception or run time error). Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] ExitProc
On Thu, 29 Jun 2006, Jonas Maebe wrote: On 29 jun 2006, at 13:51, Carsten Bager wrote: If I compile and run my example program and then press Crtl+C the program terminates. I would expect that it terminate by calling CloseServer procedure, but it dos not. If the program terminates normally (time runs out) the CloseServer procedure is called as expected. Have I misunderstood something about the ExitProc. ExitProc is only called if your program exits via the RTL. This is the case when the program exits normally, or when a run time error or unhandled exception occurs. ctrl-c is not caught by the FPC RTL. This means it is handled by the operating system, and the default action of the operating system is to simply terminate the process. The FPC RTL therefore does not get any chance to call your exitproc. I don't know whether there's a platform-independent way in the RTL to turn on the catching of ctrl-c (and converting it to an exception or run time error). Not that I am aware of... Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] ExitProc
Michael Van Canneyt wrote: On Thu, 29 Jun 2006, Jonas Maebe wrote: On 29 jun 2006, at 13:51, Carsten Bager wrote: If I compile and run my example program and then press Crtl+C the program terminates. I would expect that it terminate by calling CloseServer procedure, but it dos not. If the program terminates normally (time runs out) the CloseServer procedure is called as expected. Have I misunderstood something about the ExitProc. ExitProc is only called if your program exits via the RTL. This is the case when the program exits normally, or when a run time error or unhandled exception occurs. ctrl-c is not caught by the FPC RTL. This means it is handled by the operating system, and the default action of the operating system is to simply terminate the process. The FPC RTL therefore does not get any chance to call your exitproc. I don't know whether there's a platform-independent way in the RTL to turn on the catching of ctrl-c (and converting it to an exception or run time error). Not that I am aware of... Well, unit Crt should allow it if implemented properly (i.e. compatible to TP/BP - at least IIRC)... ;-) Not that we'd have such an implementation at the moment, though. Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal