Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-04

How to restart application after crash

8 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

I would like to create a custom 'exception handler dialog' for our applications to hook into Application.OnException(). It must have some options like saving a backtrace or copying the backtrace to the clipboard (including some system information). I also want to include a button to restart the application.

How to I do the latter part? Restart the application from within the application?

Regards,
- Graeme -

_______________________________________________________ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 10 lines
Hi, I would like to create a custom 'exception handler dialog' for our applications to hook into Application.OnException(). It must have some options like saving a backtrace or copying the backtrace to the clipboard (including some system information). I also want to include a button to restart the application. How to I do the latter part? Restart the application from within the application?
ExecuteProcess(ParamStr(0),options);

?

Michael.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote
ExecuteProcess(ParamStr(0),options);

That's not going to work, because ExecuteProcess waits for the process to complete before it returns. I forgot Lazarus has a File|Restart option, so I'll have a look to see what they did.

Regards,
- Graeme -

_______________________________________________________ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

ik
to Graeme Geldenhuys: I would like to create a custom 'exception handler dialog' for our applications to hook…

On *nix you can try the execv family. Some of them (I don't remember by hart) open a new process without caring on the parent prosess.

On Windows try ShellExecute or something in that family.

Ido

Graeme Geldenhuys wrote 25 lines
Hi, I would like to create a custom 'exception handler dialog' for our applications to hook into Application.OnException(). It must have some options like saving a backtrace or copying the backtrace to the clipboard (including some system information). I also want to include a button to restart the application. How to I do the latter part? Restart the application from within the application? Regards, - Graeme - _______________________________________________________ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/ _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Graeme Geldenhuys
to ik
ik wrote 5 lines
On *nix you can try the execv family. Some of them (I don't remember by hart) open a new process without caring on the parent prosess. On Windows try ShellExecute or something in that family.

Is there any reason I cannot use TProcess? So far it seems to work (that's if I don't get my application in a never ending restart loop) :-)

I don't really know the 'process' unit, but will browse the source to see if I can learn something.

Regards,
- Graeme -

_______________________________________________________ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys: That's not going to work, because ExecuteProcess waits for the process to complete before…
Graeme Geldenhuys wrote 7 lines
Michael Van Canneyt wrote: > > ExecuteProcess(ParamStr(0),options); That's not going to work, because ExecuteProcess waits for the process to complete before it returns. I forgot Lazarus has a File|Restart option, so I'll have a look to see what they did.

Something like:

With Tprocess.Create(Nil) do
  try
    CmdLine:=ParamStr(0)+'all others';
    OPtions:=[];
    Execute;
  finally
    Free;
  end;

Michael.

Show quoted text 16 lines
Regards, - Graeme - _______________________________________________________ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/ _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Felipe Monteiro de Carvalho
to Michael Van Canneyt: Something like: With Tprocess.Create(Nil) do try CmdLine:=ParamStr(0)+'all others';…

To detect a crash, I would use a separate process, because the crash may be sudden (like if the user killed it in the task manager because it hanged) and not involve any exception.

I don't know if having the main application create a watcher process could couse trouble, if the os automatically ends child processes. If this is the case you would need to create a starter application and start your app from it.

Felipe Monteiro de Carvalho

Reply by email