On Fri, Jul 15, 2022 at 11:41:34AM +0100, Richard W.M. Jones wrote:
val output_to_local_file : ?changeuid:((unit -> unit) -> unit)
->
- ?compressed:bool ->
+ ?compressed:bool -> ?on_exit_kill:bool ->
Types.output_allocation ->
string -> string -> int64 -> string ->
- unit
+ int
(** When an output mode wants to create a local file with a
particular format (only "raw" or "qcow2" allowed) then
- this common function can be used. *)
+ this common function can be used.
+
+ Exit handling:
+
+ [?on_exit_kill] defaults to true. Most callers can leave that alone,
+ and also ignore the returned PID. The NBD server will be cleaned up
+ automatically with no further action required.
+
+ However if you need to wait for the NBD server to be cleaned up,
+ you should set [~on_exit_kill:false] and then waitpid on the
+ returned PID. *)
To avoid so much churn, another way to do this would be to have some
kind of bi-state or tri-state flag, eg:
type on_exit_kill = Kill | KillAndWait [ | Nothing ]
and then hide the behaviour inside output_to_local_file.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW