diff options
-rw-r--r-- | libguile/async.c | 10 | ||||
-rw-r--r-- | libguile/fports.c | 6 | ||||
-rw-r--r-- | libguile/posix.c | 7 | ||||
-rw-r--r-- | libguile/scmsigs.c | 5 | ||||
-rw-r--r-- | libguile/threads.c | 15 |
5 files changed, 31 insertions, 12 deletions
diff --git a/libguile/async.c b/libguile/async.c index 87d330d60..bf03c48bd 100644 --- a/libguile/async.c +++ b/libguile/async.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2002, 2004, 2006 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2002, 2004, 2006, 2008 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -41,6 +41,8 @@ #include <unistd.h> #endif +#include <full-write.h> + /* {Asynchronous Events} * @@ -241,13 +243,13 @@ scm_i_queue_async_cell (SCM c, scm_i_thread *t) if (sleep_fd >= 0) { char dummy = 0; + /* Likewise, T might already been done with sleeping here, but interrupting it once too often does no harm. T might also not yet have started sleeping, but this is no problem either since the data written to a pipe will not be lost, unlike a - condition variable signal. - */ - write (sleep_fd, &dummy, 1); + condition variable signal. */ + full_write (sleep_fd, &dummy, 1); } /* This is needed to protect sleep_mutex. diff --git a/libguile/fports.c b/libguile/fports.c index 9458e832c..fd825c852 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -59,6 +59,8 @@ # include <winsock2.h> #endif /* __MINGW32__ */ +#include <full-write.h> + /* Mingw (version 3.4.5, circa 2006) has ftruncate as an alias for chsize already, but have this code here in case that wasn't so in past versions, or perhaps to help other minimal DOS environments. @@ -826,9 +828,9 @@ fport_flush (SCM port) const char *msg = "Error: could not flush file-descriptor "; char buf[11]; - write (2, msg, strlen (msg)); + full_write (2, msg, strlen (msg)); sprintf (buf, "%d\n", fp->fdes); - write (2, buf, strlen (buf)); + full_write (2, buf, strlen (buf)); count = remaining; } diff --git a/libguile/posix.c b/libguile/posix.c index abcf77fcf..00e0fa1a3 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -277,7 +277,7 @@ SCM_DEFINE (scm_getgroups, "getgroups", 0, 0, 0, size = ngroups * sizeof (GETGROUPS_T); groups = scm_malloc (size); - getgroups (ngroups, groups); + ngroups = getgroups (ngroups, groups); result = scm_c_make_vector (ngroups, SCM_BOOL_F); while (--ngroups >= 0) @@ -1563,12 +1563,15 @@ SCM_DEFINE (scm_nice, "nice", 1, 0, 0, "The return value is unspecified.") #define FUNC_NAME s_scm_nice { + int nice_value; + /* nice() returns "prio-NZERO" on success or -1 on error, but -1 can arise from "prio-NZERO", so an error must be detected from errno changed */ errno = 0; - nice (scm_to_int (incr)); + nice_value = nice (scm_to_int (incr)); if (errno != 0) SCM_SYSERROR; + return SCM_UNSPECIFIED; } #undef FUNC_NAME diff --git a/libguile/scmsigs.c b/libguile/scmsigs.c index 237bc5323..eb7cec67b 100644 --- a/libguile/scmsigs.c +++ b/libguile/scmsigs.c @@ -63,6 +63,9 @@ #define pipe(fd) _pipe (fd, 256, O_BINARY) #endif +#include <full-write.h> + + /* SIGRETTYPE is the type that signal handlers return. See <signal.h> */ @@ -137,7 +140,7 @@ static SIGRETTYPE take_signal (int signum) { char sigbyte = signum; - write (signal_pipe[1], &sigbyte, 1); + full_write (signal_pipe[1], &sigbyte, 1); #ifndef HAVE_SIGACTION signal (signum, take_signal); diff --git a/libguile/threads.c b/libguile/threads.c index ef52337f6..1d497e72b 100644 --- a/libguile/threads.c +++ b/libguile/threads.c @@ -61,6 +61,9 @@ # define pipe(fd) _pipe (fd, 256, O_BINARY) #endif /* __MINGW32__ */ +#include <full-read.h> + + static void to_timespec (SCM t, scm_t_timespec *waittime) { @@ -480,8 +483,13 @@ guilify_self_1 (SCM_STACKITEM *base) t->sleep_mutex = NULL; t->sleep_object = SCM_BOOL_F; t->sleep_fd = -1; - /* XXX - check for errors. */ - pipe (t->sleep_pipe); + + if (pipe (t->sleep_pipe) != 0) + /* FIXME: Error conditions during the initialization phase are handled + gracelessly since public functions such as `scm_init_guile ()' + currently have type `void'. */ + abort (); + scm_i_pthread_mutex_init (&t->heap_mutex, NULL); scm_i_pthread_mutex_init (&t->admin_mutex, NULL); t->clear_freelists_p = 0; @@ -1776,7 +1784,8 @@ scm_std_select (int nfds, if (res > 0 && FD_ISSET (wakeup_fd, readfds)) { char dummy; - read (wakeup_fd, &dummy, 1); + full_read (wakeup_fd, &dummy, 1); + FD_CLR (wakeup_fd, readfds); res -= 1; if (res == 0) |