The interrupt service routine trigger() should simply set a flag that the interrupt occurred, and exit. All other actions are carried out by the main program.
That flag might be a volatile global variable set equal to 1, which is reset to zero when the main program finishes the intended action.