[vlc-commits] cli: implement logout in normal (non-socket) mode

Rémi Denis-Courmont git at videolan.org
Sun Oct 18 20:26:04 CEST 2020


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Oct 18 21:11:30 2020 +0300| [f5f6ce1305f466c34f0f58267d19f41a43fe58c6] | committer: Rémi Denis-Courmont

cli: implement logout in normal (non-socket) mode

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f5f6ce1305f466c34f0f58267d19f41a43fe58c6
---

 modules/control/cli/cli.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index 755daf9971..ed7df6b83f 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -225,6 +225,19 @@ static void LogOut(intf_thread_t *intf, const char *const *args, size_t count)
         sys->stream = NULL;
         sys->fd = -1;
     }
+    else
+    {   /* Force end-of-file on the standard input. */
+        int fd = vlc_open("/dev/null", O_RDONLY);
+        if (fd != -1)
+        {   /* POSIX requires flushing before, and seeking after, replacing a
+             * file descriptor underneath an I/O stream.
+             */
+            fflush(sys->stream);
+            dup2(fd, 0 /* fileno(sys->stream) */);
+            fseek(sys->stream, 0, SEEK_SET);
+            vlc_close(fd);
+        }
+    }
 #else
     if (sys->i_socket != -1)
     {



More information about the vlc-commits mailing list