don't hang in form when stdin disappears
This commit is contained in:
parent
e29db34920
commit
fb292df6aa
132
newt-0.52.12-nostdin.patch
Normal file
132
newt-0.52.12-nostdin.patch
Normal file
@ -0,0 +1,132 @@
|
||||
From f16b3d1ac2edaceb64463f29a3e394a0102aa554 Mon Sep 17 00:00:00 2001
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Wed, 10 Nov 2010 17:57:11 +0100
|
||||
Subject: [PATCH 1/2] don't call exit in library
|
||||
|
||||
The feof() detection of closed stdin doesn't work anyway.
|
||||
---
|
||||
newt.c | 3 ---
|
||||
1 files changed, 0 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/newt.c b/newt.c
|
||||
index f3f49ff..4e37bc1 100644
|
||||
--- a/newt.c
|
||||
+++ b/newt.c
|
||||
@@ -565,10 +565,7 @@ int newtGetKey(void) {
|
||||
if (key == SLANG_GETKEY_ERROR) {
|
||||
/* Either garbage was read, or stdin disappeared
|
||||
* (the parent terminal was proably closed)
|
||||
- * if the latter, die.
|
||||
*/
|
||||
- if (feof(stdin))
|
||||
- exit(1);
|
||||
if (needResize) {
|
||||
needResize = 0;
|
||||
return NEWT_KEY_RESIZE;
|
||||
--
|
||||
1.7.3.2
|
||||
|
||||
From b8b8a86f22d08216328dffb8d70b3ae67629a905 Mon Sep 17 00:00:00 2001
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Wed, 10 Nov 2010 18:10:46 +0100
|
||||
Subject: [PATCH 2/2] return NEWT_EXIT_ERROR from form when stdin disappears
|
||||
|
||||
---
|
||||
form.c | 9 ++++++++-
|
||||
newt.c | 15 ++++++++-------
|
||||
newt.h | 3 ++-
|
||||
3 files changed, 18 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/form.c b/form.c
|
||||
index 24542a0..5b421fb 100644
|
||||
--- a/form.c
|
||||
+++ b/form.c
|
||||
@@ -841,7 +841,8 @@ newtComponent newtRunForm(newtComponent co) {
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
- }
|
||||
+ } else if (es.reason == NEWT_EXIT_ERROR)
|
||||
+ return NULL;
|
||||
|
||||
return es.u.co;
|
||||
}
|
||||
@@ -1072,6 +1073,12 @@ void newtFormRun(newtComponent co, struct newtExitStruct * es) {
|
||||
}
|
||||
}
|
||||
|
||||
+ if (key == NEWT_KEY_ERROR) {
|
||||
+ es->u.watch = -1;
|
||||
+ es->reason = NEWT_EXIT_ERROR;
|
||||
+ done = 1;
|
||||
+ }
|
||||
+
|
||||
if (!done) {
|
||||
ev.event = EV_KEYPRESS;
|
||||
ev.u.key = key;
|
||||
diff --git a/newt.c b/newt.c
|
||||
index 4e37bc1..ab41dd8 100644
|
||||
--- a/newt.c
|
||||
+++ b/newt.c
|
||||
@@ -555,29 +555,30 @@ static void kmap_trie_fallback(struct kmap_trie_entry *to,
|
||||
}
|
||||
|
||||
int newtGetKey(void) {
|
||||
- int key;
|
||||
+ int key, lastcode, errors = 0;
|
||||
unsigned char *chptr = keyreader_buf, *lastmatch;
|
||||
- int lastcode;
|
||||
struct kmap_trie_entry *curr = kmap_trie_root;
|
||||
|
||||
do {
|
||||
key = getkey();
|
||||
if (key == SLANG_GETKEY_ERROR) {
|
||||
- /* Either garbage was read, or stdin disappeared
|
||||
- * (the parent terminal was proably closed)
|
||||
- */
|
||||
if (needResize) {
|
||||
needResize = 0;
|
||||
return NEWT_KEY_RESIZE;
|
||||
}
|
||||
|
||||
- /* ignore other signals */
|
||||
+ /* Ignore other signals, but assume that stdin disappeared (the
|
||||
+ * parent terminal was proably closed) if the error persists.
|
||||
+ */
|
||||
+ if (errors++ > 10)
|
||||
+ return NEWT_KEY_ERROR;
|
||||
+
|
||||
continue;
|
||||
}
|
||||
|
||||
if (key == NEWT_KEY_SUSPEND && suspendCallback)
|
||||
suspendCallback(suspendCallbackData);
|
||||
- } while (key == NEWT_KEY_SUSPEND);
|
||||
+ } while (key == NEWT_KEY_SUSPEND || key == SLANG_GETKEY_ERROR);
|
||||
|
||||
/* Read more characters, matching against the trie as we go */
|
||||
lastcode = *chptr = key;
|
||||
diff --git a/newt.h b/newt.h
|
||||
index 3111a21..f71ce1e 100644
|
||||
--- a/newt.h
|
||||
+++ b/newt.h
|
||||
@@ -217,7 +217,7 @@ char * newtReflowText(char * text, int width, int flexDown, int flexUp,
|
||||
|
||||
struct newtExitStruct {
|
||||
enum { NEWT_EXIT_HOTKEY, NEWT_EXIT_COMPONENT, NEWT_EXIT_FDREADY,
|
||||
- NEWT_EXIT_TIMER } reason;
|
||||
+ NEWT_EXIT_TIMER, NEWT_EXIT_ERROR } reason;
|
||||
union {
|
||||
int watch;
|
||||
int key;
|
||||
@@ -307,6 +307,7 @@ void newtComponentDestroy(newtComponent co);
|
||||
|
||||
/* not really a key, but newtGetKey returns it */
|
||||
#define NEWT_KEY_RESIZE NEWT_KEY_EXTRA_BASE + 113
|
||||
+#define NEWT_KEY_ERROR NEWT_KEY_EXTRA_BASE + 114
|
||||
|
||||
#define NEWT_ANCHOR_LEFT (1 << 0)
|
||||
#define NEWT_ANCHOR_RIGHT (1 << 1)
|
||||
--
|
||||
1.7.3.2
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
Summary: A library for text mode user interfaces
|
||||
Name: newt
|
||||
Version: 0.52.12
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
License: LGPLv2
|
||||
Group: System Environment/Libraries
|
||||
URL: https://fedorahosted.org/newt/
|
||||
@ -11,6 +11,7 @@ BuildRequires: popt-devel python-devel slang-devel
|
||||
BuildRequires: docbook-utils
|
||||
Provides: snack = %{version}-%{release}
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
Patch0: newt-0.52.12-nostdin.patch
|
||||
|
||||
%package devel
|
||||
Summary: Newt windowing toolkit development files
|
||||
@ -57,6 +58,7 @@ providing a python API for creating text mode ionterfaces.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch0 -p1 -b .nostdin
|
||||
|
||||
%build
|
||||
# gpm support seems to smash the stack w/ we use help in anaconda??
|
||||
@ -104,6 +106,9 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%{python_sitearch}/*.py*
|
||||
|
||||
%changelog
|
||||
* Wed Nov 10 2010 Miroslav Lichvar <mlichvar@redhat.com> - 0.52.12-2
|
||||
- don't hang in form when stdin disappears
|
||||
|
||||
* Fri Aug 06 2010 Miroslav Lichvar <mlichvar@redhat.com> - 0.52.12-1
|
||||
- fix whiptail --gauge and its description in man page (#620083)
|
||||
- remove space after \n in whiptail texts (#620083)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user