summaryrefslogtreecommitdiffstats
path: root/sysprep/sysprep_operation_script.ml
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-04-01 20:00:06 +0100
committerRichard W.M. Jones <rjones@redhat.com>2012-04-01 20:00:06 +0100
commitde656448f7949d2b04e75455d5a2233d0c5856b9 (patch)
treeb23f893f19d0dc1ee4b7e5560199f4e2b6d3b5bd /sysprep/sysprep_operation_script.ml
parent6c88ae851f80e766a94576fcea7c701994de05cc (diff)
downloadlibguestfs-de656448f7949d2b04e75455d5a2233d0c5856b9.tar.gz
libguestfs-de656448f7949d2b04e75455d5a2233d0c5856b9.tar.xz
libguestfs-de656448f7949d2b04e75455d5a2233d0c5856b9.zip
sysprep: script: Wait for child process to exit.
Diffstat (limited to 'sysprep/sysprep_operation_script.ml')
-rw-r--r--sysprep/sysprep_operation_script.ml20
1 files changed, 17 insertions, 3 deletions
diff --git a/sysprep/sysprep_operation_script.ml b/sysprep/sysprep_operation_script.ml
index a6591759..5e47733b 100644
--- a/sysprep/sysprep_operation_script.ml
+++ b/sysprep/sysprep_operation_script.ml
@@ -52,13 +52,26 @@ let rec script_perform (g : Guestfs.guestfs) root =
g#mount_local scriptdir;
(* Run the script(s)/program(s). *)
- run_scripts scriptdir scripts;
+ let pid = run_scripts scriptdir scripts in
(* Run FUSE. *)
g#mount_local_run ();
+ let ok =
+ match snd (waitpid [] pid) with
+ | WEXITED 0 -> true
+ | WEXITED i ->
+ eprintf "virt-sysprep: script: failed (code %d)\n" i;
+ false
+ | WSIGNALED i
+ | WSTOPPED i ->
+ eprintf "virt-sysprep: script: killed by signal (%d)\n" i;
+ false in
+
(* Remote temporary directory / mountpoint. *)
- if cleanup then rmdir scriptdir
+ if cleanup then rmdir scriptdir;
+
+ if not ok then failwith "script failed"
);
[]
@@ -87,7 +100,8 @@ trap sysprep_unmount INT TERM QUIT EXIT ERR\n" (Filename.quote mp) ^
if pid = 0 then ( (* child *)
chdir mp;
execv sh args
- )
+ );
+ pid
let script_op = {
name = "script";