let at_exit_once callback = let pid = Unix.getpid () in at_exit begin fun () -> if pid = Unix.getpid () then callback () end