From 591193eb7750be070ea1286190df31f03179fc11 Mon Sep 17 00:00:00 2001 From: Frank Benkstein Date: Fri, 12 Oct 2007 05:31:40 +0200 Subject: [PATCH] src/script.c: fix cat typing bug If a script plugin blocks and a domestic animal sits on the escape key long enough vlock will lock up when the write buffer of the pipe runs full. Setting O_NONBLOCK fixes the issue. --- src/script.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/script.c b/src/script.c index de9e884..c74011e 100644 --- a/src/script.c +++ b/src/script.c @@ -159,6 +159,7 @@ static bool call_script_hook(struct plugin *s, const char *hook_name) static struct script_context *launch_script(const char *path) { + int fd_flags; struct script_context *script = malloc(sizeof *script); const char *argv[] = { path, "hooks", NULL }; struct child_process child = { @@ -183,6 +184,13 @@ static struct script_context *launch_script(const char *path) script->fd = child.stdin_fd; script->pid = child.pid; + fd_flags = fcntl(script->fd, F_GETFL, &fd_flags); + + if (fd_flags != -1) { + fd_flags |= O_NONBLOCK; + (void) fcntl(script->fd, F_SETFL, fd_flags); + } + return script; } -- 2.11.4.GIT