search for: stdio_check

Displaying 3 results from an estimated 3 matches for "stdio_check".

2020 Apr 14
0
[nbdkit PATCH v2 3/3] server: More tests of stdin/out handling
...stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> +#include <unistd.h> + +#define NBDKIT_API_VERSION 2 + +#include <nbdkit-plugin.h> + +static const char *msg = "input"; + +/* Check whether stdin/out match /dev/null */ +static bool +stdio_check (void) +{ + static int dn = -1; + struct stat st1, st2; + + if (dn == -1) { + dn = open ("/dev/null", O_RDONLY); + assert (dn > STDERR_FILENO); + } + if (fstat (dn, &st1) == -1) + assert (false); + + if (fstat (STDIN_FILENO, &st2) == -1) + assert (false); + i...
2020 Apr 14
6
[nbdkit PATCH v2 0/3] more consistent stdin/out handling
In v2: - use int instead of bool in the public header - split the tests from the code - don't overload test-layers; instead, add new tests - add a missing fflush exposed by the new tests - other minor cleanups Eric Blake (3): server: Add nbdkit_stdio_safe server: Sanitize stdin/out before running plugin code server: More tests of stdin/out handling docs/nbdkit-plugin.pod |
2020 Aug 05
2
[PATCH nbdkit 1/2] server: Call .get_ready before redirecting stdin/stdout to /dev/null.
...op); start_serving (); diff --git a/tests/test-stdio-plugin.c b/tests/test-stdio-plugin.c index 618eae83..86447278 100644 --- a/tests/test-stdio-plugin.c +++ b/tests/test-stdio-plugin.c @@ -122,6 +122,14 @@ stdio_config_complete (void) static int stdio_get_ready (void) +{ + bool check = stdio_check (); + assert (check == false); + return 0; +} + +static int +stdio_after_fork (void) { bool check = stdio_check (); assert (check == true); @@ -163,6 +171,7 @@ static struct nbdkit_plugin plugin = { .config = stdio_config, .config_complete = stdio_config_complete, .ge...