Could you daemonize something in this way? Run something you want to be permanently running, and then exit trap to run the same script. I have a few long running bash scripts and use cron jobs currently to make sure they keep operating, but this looks like an interesting replacement.
You could, but it wouldn’t necessarily be very robust; for example, a SIGKILL will prevent the exit trap from executing. You’d also have no way of doing health checks.
If you have the option to use a modern service manager like systemd, you’d be much better to just use the existing service management tools than reimplement your own adhoc ones.
I can’t speak in detail to other systems, but systemd unit files are incredibly painless to write and run and are very robust.