Exec through an exception to make sure everything is closed properly

Closes #1535

Also sets the CLOEXEC flag on locks, to make sure they're not inherited
Disable the O_CLOEXEC flag for compat with OCaml 3.12

Would be safer with it, but the rest of the fix should be enough for the case at hand
Merge pull request #1542 from OCamlPro/fix-config-exec

Exec through an exception to make sure everything is closed properly