commit eab21e5857e7b19a06196ec7a9c197bc599560a0
parent bb225300e267a55fb40cf082de04567129652bda
Author: tgoodwin <tgoodwin>
Date: Wed, 18 Feb 1998 17:10:53 +0000
reinstate rc_wait (but right this time)
Diffstat:
4 files changed, 41 insertions(+), 19 deletions(-)
diff --git a/rc.h b/rc.h
@@ -362,14 +362,6 @@ extern Node *parsetree;
extern int yyparse(void);
extern void initparse(void);
-/* rdwr.c */
-extern void writeall(int, char *, size_t);
-extern int rc_read(int, char *, size_t);
-
-#if READLINE
-extern char *rc_readline(char *prompt);
-#endif
-
/* redir.c */
extern void doredirs(void);
@@ -392,6 +384,26 @@ extern void statprint(pid_t, int);
extern void ssetstatus(char **);
extern char *strstatus(int s);
+
+/* system.c or system-bsd.c */
+extern void writeall(int, char *, size_t);
+
+#if HAVE_RESTARTABLE_SYSCALLS
+extern int rc_read(int, char *, size_t);
+#if READLINE
+extern char *rc_readline(char *prompt);
+#endif
+
+#else /* HAVE_RESTARTABLE_SYSCALLS */
+#define rc_read read
+#define rc_wait wait
+#if READLINE
+#define rc_readline readline
+#endif
+
+#endif /* HAVE_RESTARTABLE_SYSCALLS */
+
+
/* tree.c */
extern Node *mk(int /*nodetype*/,...);
extern Node *treecpy(Node *, void *(*)(size_t));
diff --git a/system-bsd.c b/system-bsd.c
@@ -32,6 +32,7 @@ extern void writeall(int fd, char *buf, size_t remain) {
extern int rc_read(int fd, char *buf, size_t n) {
ssize_t r;
+
interrupt_happened = FALSE;
if (!sigsetjmp(slowbuf.j, 1)) {
slow = TRUE;
@@ -49,6 +50,25 @@ extern int rc_read(int fd, char *buf, size_t n) {
return r;
}
+static r = -1;
+extern pid_t rc_wait(int *stat) {
+ interrupt_happened = FALSE;
+ if (!sigsetjmp(slowbuf.j, 1)) {
+ slow = TRUE;
+ if (!interrupt_happened)
+ r = wait(stat);
+ else
+ r = -2;
+ } else
+ r = -2;
+ slow = FALSE;
+ if (r == -2) {
+ errno = EINTR;
+ r = -1;
+ }
+ return r;
+}
+
/* signal-safe readline wrapper */
#if READLINE
extern char *rc_readline(char *prompt) {
diff --git a/system.c b/system.c
@@ -8,13 +8,3 @@ extern void writeall(int fd, char *buf, size_t remain) {
break; /* abort silently on errors in write() */
sigchk();
}
-
-extern int rc_read(int fd, char *buf, size_t n) {
- return read(fd, buf, n);
-}
-
-#if READLINE
-extern char *rc_readline(char *prompt) {
- return readline(prompt);
-}
-#endif
diff --git a/wait.c b/wait.c
@@ -67,7 +67,7 @@ extern pid_t rc_wait4(pid_t pid, int *stat, bool nointr) {
int ret;
Pid *q;
- ret = wait(stat);
+ ret = rc_wait(stat);
if (ret < 0) {
if (errno == ECHILD)