* express or implied warranty.
*/
+#include "config.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#endif
static char MORE[] = "more";
-extern char *_ss_pager_name;
extern char *getenv PROTOTYPE((const char *));
char *ss_safe_getenv(const char *arg)
#endif
#endif
-#ifdef HAVE___SECURE_GETENV
+#if defined(HAVE_SECURE_GETENV)
+ return secure_getenv(arg);
+#elif defined(HAVE___SECURE_GETENV)
return __secure_getenv(arg);
#else
return getenv(arg);
}
#endif
-void ss_page_stdin()
+static int write_all(int fd, char *buf, size_t count)
+{
+ ssize_t ret;
+ int c = 0;
+
+ while (count > 0) {
+ ret = write(fd, buf, count);
+ if (ret < 0) {
+ if ((errno == EAGAIN) || (errno == EINTR))
+ continue;
+ return -1;
+ }
+ count -= ret;
+ buf += ret;
+ c += ret;
+ }
+ return c;
+}
+
+void ss_page_stdin(void)
{
int i;
sigset_t mask;
char buf[80];
register int n;
while ((n = read(0, buf, 80)) > 0)
- write(1, buf, n);
+ write_all(1, buf, n);
}
exit(errno);
}