mirror of
https://github.com/CatalaLang/catala.git
synced 2024-09-19 00:15:39 +03:00
Clerk: fix finalisation on exit
We have temporary files to remove upon `ninja` completion so it's not a good idea to `exec` without fork. This patch ensures `/tmp/clerk_*.ninja` files aren't left in `/tmp`.
This commit is contained in:
parent
affa45c115
commit
1efdf4262d
@ -935,7 +935,16 @@ let ninja_cmdline ninja_flags nin_file targets =
|
||||
let run_ninja ~clean_up_env cmdline =
|
||||
let cmd = List.hd cmdline in
|
||||
let env = if clean_up_env then cleaned_up_env () else Unix.environment () in
|
||||
Unix.execvpe cmd (Array.of_list cmdline) env
|
||||
let npid =
|
||||
Unix.create_process_env cmd (Array.of_list cmdline) env Unix.stdin
|
||||
Unix.stdout Unix.stderr
|
||||
in
|
||||
let return_code =
|
||||
match Unix.waitpid [] npid with
|
||||
| _, Unix.WEXITED n -> n
|
||||
| _, (Unix.WSIGNALED n | Unix.WSTOPPED n) -> 128 - n
|
||||
in
|
||||
raise (Catala_utils.Cli.Exit_with return_code)
|
||||
|
||||
open Cmdliner
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user