nbdkit_stdio_safe(3)

πŸ’– nbdkit_stdio_safe β€” is it safe to interact with stdin and stdout πŸ’–

okay bestie, welcome to the nbdkit manual, section 3. this one's short and sweet and honestly iconic for how much chaos it prevents. let's get into it 🫢


✨ SYNOPSIS ✨

#include <nbdkit-plugin.h>

int nbdkit_stdio_safe (void);

🌸 DESCRIPTION 🌸

so like. the nbdkit_stdio_safe utility function returns whether or not it's safe to interact with stdin and stdout during the configuration phase. that's it, that's the whole job, no cap.

why does this even exist?? because when the nbdkit -s option is used, the plugin must not directly interact with stdin β€” that would interfere with network communication. and we do NOT want to be fighting the network for stdin, that's giving main character energy from the wrong character πŸ’€

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. so like, after that point? all bets are off, bestie, assume the stdio is gone ✨

nbdkit-sh-plugin(3) uses this function to determine whether it's safe to support script=- to read a script from stdin. also constructs like password=- (see nbdkit_read_password(3)) get disabled when reading from stdio is not safe. love that for us, honestly β€” the function just quietly protects everybody πŸŽ€


⭐ RETURN VALUE ⭐

  • returns 1 when it's safe
  • returns 0 when it's not safe

and that's it. it literally cannot return an error. no error codes, no errno drama, no nothing. it's giving emotionally stable function πŸ’…


πŸ¦‹ 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

look at all these languages showing up for the function. multilingual queen πŸ‘‘


🌈 HISTORY 🌈

nbdkit_stdio_safe was added in nbdkit 1.20. a relatively recent addition to the family, and we're obsessed πŸ₯³


πŸ‘‘ SEE ALSO πŸ‘‘


πŸ’œ AUTHORS πŸ’œ

Eric Blake β€” thank you for your service, king 🫑


Copyright Red Hat


πŸ“œ LICENSE πŸ“œ

so legally speaking, redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met (yes, all three, no skipping, iykyk):

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of Red Hat nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
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.

like, the lawyers wrote that one, not me, and honestly they ate πŸ”₯


okay that's the whole page bestie!! this one comes to you from nbdkit-1.48.1, dated 2026-08-29, page nbdkit_stdio_safe(3). stay safe out there, check your stdio, and never talk to stdin without permission πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

πŸ“¦ where this page comes from