Artificial intelligent assistant

Construct a while loop around a command throwing a segmentation fault I have a program that throws a segmentation fault on certain circumstances. I want to execute a command when the segmentation fault occurs to process the data, then execute the command again, and keep doing so until the segmentation fault stops. As a rough attempt at pseudo code, dodgy_command while SegFault dataProcessing dodgy_command end I think I need to be using a Trap command, but I don't understand the syntax for this command.

When a program aborts abnormally the exit code (as seen by the shell) typically has the high bit set so the value is 128 or higher. So a simple solution might be


dodgy_command

while [ $? -ge 128 ]
do
process_data
dodgy_command
done


If you specifically only want a segfault and not any other type of error, the while line becomes `$? -eq 139` (because SEGV is signal 11; 128+11=139).

If you don't get an high valued exit code on failure then it probably means the application is trapping the error, itself, and forcing a different exit code.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 5cd8185d45e0d90c526edf42d7b1e3dc