The best solution might be to keep all the processes unaware of each other and use a separate watchdog/supervising process to monitor them and automatically restart ones that go down. Examples are Supervisor or perp.
If you want it to behave exactly as you say, you could have each process store their pid in the database (or in a file), or send a heartbeat periodically (storing time of last activity in the database, or touching a file on disk). The table/file would also contain the process_flag. Then in between jobs the other processes could check this and see if any of the pids are for no longer running processes, or if the heartbeat hasn't been updated in a while. Then they could "claim" that process_flag and update the row/file atomically.
But... if you do all that you're basically making each process a process monitor. So to keep it simple you could split out that monitoring code into a separate process. But then you've basically written a replacement for one of the existing tools you could have been using.
A concern people have about using a watchdog is what to do if it crashes itself. One solution is to have a cron that periodically starts it up if it's no longer running.