URI:
       sfeed_curses: fix: open /dev/null for reading and writing - sfeed - RSS and Atom parser
  HTML git clone git://git.codemadness.org/sfeed
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 45fba594ca26328ae1d7ba3b133983755af1d745
   DIR parent 30fbd4578cfec6d12549bd9f99a2b9677b5c668f
  HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Wed,  8 Apr 2026 20:14:03 +0200
       
       sfeed_curses: fix: open /dev/null for reading and writing
       
       It was opened just for writing. This is incorrect, because in forkexec() in
       non-interactive mode (used for plumbing), a program could read from stdin:
       
               dup2(devnullfd, 0); /* stdin */
       
       A read() in the program will return with errno = EBADF, because the descriptor
       can only be written to (O_WRONLY).
       
       Because stderr output was written to /dev/null also, this error was not visible
       if a program would report a read error either.
       
       To reproduce:
       
       plumb.sh:
       
               #!/bin/sh
               # ignore $1
               cat
       
       Run:
               SFEED_PLUMBER="./plumb.sh" strace -o strace.log -ff sfeed_curses < items.tsv
       
       In the strace log for the plumbed program the read error is visible:
       
               read(0, 0xaddr, 131072)         = -1 EBADF (Bad file descriptor)
       
       Diffstat:
         M sfeed_curses.c                      |       2 +-
       
       1 file changed, 1 insertion(+), 1 deletion(-)
       ---
   DIR diff --git a/sfeed_curses.c b/sfeed_curses.c
       @@ -2012,7 +2012,7 @@ main(int argc, char *argv[])
                if (argc <= 1)
                        feeds[0].fp = NULL;
        
       -        if ((devnullfd = open("/dev/null", O_WRONLY)) == -1)
       +        if ((devnullfd = open("/dev/null", O_RDWR)) == -1)
                        die("open: /dev/null");
        
                init();