NAME

nbdkit_stdio_safe - is it safe to interact with stdin and stdout

SYNOPSIS

 #include <nbdkit-plugin.h>

 int nbdkit_stdio_safe (void);

DESCRIPTION

The nbdkit_stdio_safe utility function returns whether or not it is safe to interact with stdin and stdout during the configuration phase.

This is needed because when the nbdkit -s option is used the plugin must not directly interact with stdin, because that would interfere with network communication.

The result of this function only matters in callbacks up to .config_complete. Once nbdkit reaches .get_ready, the plugin should assume that nbdkit may have closed the original stdin and stdout in order to become a daemon.

nbdkit-sh-plugin(3) uses this function to determine whether it is safe to support script=- to read a script from stdin. Also constructs like password=- (see nbdkit_read_password(3)) are disabled when reading from stdio is not safe.

RETURN VALUE

The function returns 1 (safe) or 0 (not safe).

It cannot return an error.

LANGUAGE BINDINGS

In nbdkit-ocaml-plugin(3):

 NBDKit.stdio_safe : unit -> bool

In nbdkit-python-plugin(3):

 import nbdkit
 is_safe = nbdkit.stdio_safe()

In nbdkit-rust-plugin(3):

 use nbdkit::*;
 pub fn is_stdio_safe() -> bool

HISTORY

nbdkit_stdio_safe was added in nbdkit 1.20.

SEE ALSO

nbdkit(1), nbdkit_read_password(3), nbdkit-plugin(3), nbdkit-filter(3).

AUTHORS

Eric Blake

COPYRIGHT

Copyright Red Hat

LICENSE

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.