Self restart program on segfault under Linux

Waxhead picture Waxhead · Sep 13, 2010 · Viewed 7.6k times · Source

Under Linux what would be the best way for a program to restart itself on a crash by catching the exception in a crashhandler (for example on a segfault)?

Answer

Anycorn picture Anycorn · Sep 13, 2010

simplest is

while [ 1 ]; do ./program && break; done

basically, you run program until it is return 0, then you break.