Bug 251006

Summary: devel/cdialog timeouts not working
Product: Ports & Packages Reporter: nkoch
Component: Individual Port(s)Assignee: Mateusz Piotrowski <0mp>
Status: Closed Not A Bug    
Severity: Affects Many People CC: 0mp, jcpierri
Priority: --- Flags: jcpierri: maintainer-feedback+
Version: Latest   
Hardware: Any   
OS: Any   

Description nkoch 2020-11-10 09:34:16 UTC
DIALOG_ESC=1 DIALOG_ERROR=3 cdialog --timeout 2 --yesno Start? 0 0 ; echo $?

When doing this under FreeBSD 10.3 with cdialog 20160828, timeout is returned as error (3).

Under FreeBSD 12.1 with cdialog 20180621 or 20200327 I get esc (1) instead.
So I have no chance to see if either  no key is pressed or esc is pressed.


DIALOG_ESC=1 DIALOG_ERROR=3 cdialog --pause Start? 0 0 2; echo $?

This does not work either. The dialog box just hangs until any key has been pressed.
Comment 1 Mateusz Piotrowski freebsd_committer freebsd_triage 2020-11-10 09:46:19 UTC
"DIALOG_ESC=1 DIALOG_ERROR=3 cdialog --timeout 2 --yesno Start? 0 0 ; echo $?" returns 1 on timeout on my machine as well.

It looks like a problem which should be reported upstream.

Tested on FreeBSD 13.0 with cdialog-1.3.20200327,2.
Comment 2 Josmar Calin De Pierri 2020-11-10 13:18:51 UTC
I downloaded the current source tarball from invisible-island.net and compiled it under Ubuntu 20.04 LTS, just to be sure that it was nothing FreeBSD related, and confirmed that this behaviour also happens on Ubuntu too.

I made an additional test using an old Slackware Linux that had dialog 1.2-20130523 and it behaved as expected, with (3) returned on timeouts.

I submitted a bug report to Thomas Dickey, author and maintainer of dialog.
Comment 3 nkoch 2020-11-10 15:59:08 UTC
I found this in cdialog's changelog for version 2018/06/21:

	+ modify dlg_getc() to return ESC when a timeout expires, notifying
	  callers that a quit occurred rather than exiting the application
	  (suggested by Rodrigo Freitas).

( https://invisible-island.net/dialog/CHANGES )
Comment 4 nkoch 2020-11-11 08:16:46 UTC
(In reply to nkoch from comment #3)

Thomas Dickey confirmed that this change was intentional.
Comment 5 nkoch 2020-11-11 09:14:30 UTC
Undoing the change would be trivial:

diff --git a/dialog-1.3-20200327/ui_getc.c b/dialog-1.3-20200327/ui_getc.c
--- a/dialog-1.3-20200327/ui_getc.c
+++ b/dialog-1.3-20200327/ui_getc.c
@@ -486,9 +486,7 @@ dlg_getc(WINDOW *win, int *fkey)
 	    case ERR:		/* wtimeout() in effect; check for file I/O */
 		if (interval > 0
 		    && current >= expired) {
-		    DLG_TRACE(("# dlg_getc: timeout expired\n"));
-		    ch = ESC;
-		    done = TRUE;
+		    dlg_exiterr("timeout");
 		} else if (!valid_file(stdin)
 			   || !valid_file(dialog_state.screen_output)) {
 		    DLG_TRACE(("# dlg_getc: input or output is invalid\n"));

But perhaps it would be better to make this an option.
Comment 6 Mateusz Piotrowski freebsd_committer freebsd_triage 2020-11-11 11:08:46 UTC
I am not sure if it is a good idea to keep this patch as an option in the ports tree. It sounds like it would be much better if the patch was integrated into upstream. Perhaps Thomas Dickey would like to offer your desired behavior as, e.g., a build-time option.

I'll leave the decision to the maintainer, however.
Comment 7 Josmar Calin De Pierri 2020-11-11 13:12:36 UTC
I sent this suggestion (to create an option that reverts to the old behaviour) to Thomas, however, as this change was intentional, I agree with Mateusz that it is up to him to say if that makes sense or not.

This seems like a feature change, not a bug.
Comment 8 Mateusz Piotrowski freebsd_committer freebsd_triage 2020-11-11 13:36:00 UTC
I'll close this PR for now. Please feel free to reopen it if there is something to be done on our part. Thanks!