summaryrefslogtreecommitdiff
path: root/system-bsd.c
diff options
context:
space:
mode:
authortgoodwin <tgoodwin>1998-02-18 12:30:53 +0000
committerToby Goodwin <toby@paccrat.org>2015-05-16 21:23:04 +0100
commita33cdf2c71aec230b14a0e07317e0a38d743089b (patch)
treed45ca0d1236a7e494f8e78a8fa2b28c003f70e1f /system-bsd.c
parent4682c96c0bd432f41abb6d83b9edf8bce195ce40 (diff)
move rc_readline to rdwr.c
Diffstat (limited to 'system-bsd.c')
-rw-r--r--system-bsd.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/system-bsd.c b/system-bsd.c
index 2da4b95..1f62693 100644
--- a/system-bsd.c
+++ b/system-bsd.c
@@ -31,7 +31,7 @@ extern void writeall(int fd, char *buf, size_t remain) {
}
extern int rc_read(int fd, char *buf, size_t n) {
- long /*ssize_t*/ r;
+ ssize_t r;
interrupt_happened = FALSE;
if (!sigsetjmp(slowbuf.j, 1)) {
slow = TRUE;
@@ -48,3 +48,25 @@ extern int rc_read(int fd, char *buf, size_t n) {
}
return r;
}
+
+/* signal-safe readline wrapper */
+#if READLINE
+extern char *rc_readline(char *prompt) {
+ char *r;
+
+ interrupt_happened = FALSE;
+ if (!sigsetjmp(slowbuf.j, 1)) {
+ slow = TRUE;
+ if (!interrupt_happened)
+ r = readline(prompt);
+ else
+ r = NULL;
+ } else
+ r = NULL;
+ slow = FALSE;
+ if (r == NULL)
+ errno = EINTR;
+ sigchk();
+ return r;
+}
+#endif /* READLINE */