Re: [dev] [dmenu] [patch] Use slow path if stdin is a tty

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun, 27 Jan 2019 15:29:10 +0100

On Sat, Jan 26, 2019 at 05:02:05PM +0100, dok wrote:
> Hi,
>
> This is a simple patch to prevent from being locked by having dmenu
> waiting on fgets to read from a tty with the keyboard already grabbed.
>
> cheers
>

> From d579ee3221be1bd3fb5c1cf9c9bf55a2da68882c Mon Sep 17 00:00:00 2001
> From: dok <dok_AT_grehack.fr>
> Date: Sat, 26 Jan 2019 15:49:15 +0100
> Subject: [PATCH] Use slow path if stdin is a tty
>
> If stdin is a tty and dmenu is ran with the fast option then it's
> impossible to close stdin because the keyboard is already grabbed.
> ---
> dmenu.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/dmenu.c b/dmenu.c
> index 5c835dd..6b8f51b 100644
> --- a/dmenu.c
> +++ b/dmenu.c
> _AT_@ -6,9 +6,7 @@
> #include <string.h>
> #include <strings.h>
> #include <time.h>
> -#ifdef __OpenBSD__
> #include <unistd.h>
> -#endif
>
> #include <X11/Xlib.h>
> #include <X11/Xatom.h>
> _AT_@ -754,7 +752,7 @@ main(int argc, char *argv[])
> die("pledge");
> #endif
>
> - if (fast) {
> + if (fast && !isatty(0)) {
> grabkeyboard();
> readstdin();
> } else {
> --
> 2.20.1
>

Nice, applied and pushed.

Thanks for the patch!

-- 
Kind regards,
Hiltjo
Received on Sun Jan 27 2019 - 15:29:10 CET

This archive was generated by hypermail 2.3.0 : Sun Jan 27 2019 - 15:36:07 CET