changeset 21921:ecfcc8527661

hide sys/wait.h header and provide wrappers for waitpid macros * bootstrap.conf: Use sys_wait and waitpid gnulib modules. * liboctave/wrappers/wait-wrappers.c, added liboctave/wrappers/wait-wrappers.h: New files. * changed liboctave/wrappers/module.mk: Update. * liboctave/system/syswait.h: Delete. * liboctave/system/module.mk: Update. * oct-syscalls.cc, oct-syscalls.h (wcontinue, wcoredump, wifcontinued, wifexited, wifsignaled, wifstopped, wexitstatus, wnohang, wstopsig, wtermsig, wuntraced): New functions. (waitpid): Use octave_waitpid_wrapper. * lo-cutils.c, lo-cutils.h (octave_waitpid, octave_wifexited, octave_wexitstatus, octave_wifsignaled, octave_wtermsig, octave_wcoredump, octave_wifstopped, octave_wstopsig, octave_wifcontinued): Delete. * lo-utils.h (class octave_wait): Delete. * octave-gui.cc, help.cc: Don't include sys/wait.h. * pager.cc, sighandlers.cc, syscalls.cc, toplev.cc: Use wait functions from octave::sys namespace. * main.in.cc: Use wait-wrappers.h. * src/module.mk: Update.
author John W. Eaton <jwe@octave.org>
date Thu, 16 Jun 2016 01:00:20 -0400
parents 13e0fc0dfa0c
children c34f9c182dcf
files bootstrap.conf libgui/src/octave-gui.cc libinterp/corefcn/help.cc libinterp/corefcn/pager.cc libinterp/corefcn/sighandlers.cc libinterp/corefcn/syscalls.cc libinterp/corefcn/toplev.cc liboctave/system/module.mk liboctave/system/oct-syscalls.cc liboctave/system/oct-syscalls.h liboctave/system/syswait.h liboctave/util/lo-cutils.c liboctave/util/lo-cutils.h liboctave/util/lo-utils.h liboctave/wrappers/module.mk liboctave/wrappers/wait-wrappers.c liboctave/wrappers/wait-wrappers.h src/main.in.cc src/module.mk
diffstat 19 files changed, 326 insertions(+), 325 deletions(-) [+]
line wrap: on
line diff
--- a/bootstrap.conf	Wed Jun 15 16:41:02 2016 -0400
+++ b/bootstrap.conf	Thu Jun 16 01:00:20 2016 -0400
@@ -101,6 +101,7 @@
   sys_stat
   sys_time
   sys_times
+  sys_wait
   tempname
   time
   times
@@ -112,6 +113,7 @@
   unlink
   unsetenv
   vasprintf
+  waitpid
 "
 
 # Additional xgettext options to use.  Use "\\\newline" to break lines.
--- a/libgui/src/octave-gui.cc	Wed Jun 15 16:41:02 2016 -0400
+++ b/libgui/src/octave-gui.cc	Thu Jun 16 01:00:20 2016 -0400
@@ -38,7 +38,6 @@
 #include "lo-utils.h"
 #include "oct-env.h"
 #include "oct-syscalls.h"
-#include "syswait.h"
 
 #include "octave.h"
 #include "sighandlers.h"
--- a/libinterp/corefcn/help.cc	Wed Jun 15 16:41:02 2016 -0400
+++ b/libinterp/corefcn/help.cc	Thu Jun 16 01:00:20 2016 -0400
@@ -59,7 +59,6 @@
 #include "pt-pr-code.h"
 #include "sighandlers.h"
 #include "symtab.h"
-#include "syswait.h"
 #include "toplev.h"
 #include "unwind-prot.h"
 #include "utils.h"
--- a/libinterp/corefcn/pager.cc	Wed Jun 15 16:41:02 2016 -0400
+++ b/libinterp/corefcn/pager.cc	Thu Jun 16 01:00:20 2016 -0400
@@ -30,6 +30,7 @@
 
 #include "cmd-edit.h"
 #include "oct-env.h"
+#include "oct-syscalls.h"
 #include "singleton-cleanup.h"
 
 #include "defaults.h"
@@ -108,7 +109,7 @@
 
   if (pid > 0)
     {
-      if (octave_wait::ifexited (status) || octave_wait::ifsignaled (status))
+      if (octave::sys::wifexited (status) || octave::sys::wifsignaled (status))
         {
           // Avoid warning() since that will put us back in the pager,
           // which would be bad news.
--- a/libinterp/corefcn/sighandlers.cc	Wed Jun 15 16:41:02 2016 -0400
+++ b/libinterp/corefcn/sighandlers.cc	Thu Jun 16 01:00:20 2016 -0400
@@ -46,7 +46,6 @@
 #include "sighandlers.h"
 #include "siglist.h"
 #include "sysdep.h"
-#include "syswait.h"
 #include "toplev.h"
 #include "utils.h"
 #include "variables.h"
--- a/libinterp/corefcn/syscalls.cc	Wed Jun 15 16:41:02 2016 -0400
+++ b/libinterp/corefcn/syscalls.cc	Thu Jun 16 01:00:20 2016 -0400
@@ -1146,7 +1146,7 @@
 
   int status = args(0).xint_value ("WIFEXITED: STATUS must be an integer");
 
-  return ovl (octave_wait::ifexited (status));
+  return ovl (octave::sys::wifexited (status));
 }
 
 DEFUNX ("WEXITSTATUS", FWEXITSTATUS, args, ,
@@ -1164,7 +1164,7 @@
 
   int status = args(0).xint_value ("WEXITSTATUS: STATUS must be an integer");
 
-  return ovl (octave_wait::exitstatus (status));
+  return ovl (octave::sys::wexitstatus (status));
 }
 
 DEFUNX ("WIFSIGNALED", FWIFSIGNALED, args, ,
@@ -1180,7 +1180,7 @@
 
   int status = args(0).xint_value ("WIFSIGNALED: STATUS must be an integer");
 
-  return ovl (octave_wait::ifsignaled (status));
+  return ovl (octave::sys::wifsignaled (status));
 }
 
 DEFUNX ("WTERMSIG", FWTERMSIG, args, ,
@@ -1198,7 +1198,7 @@
 
   int status = args(0).xint_value ("WTERMSIG: STATUS must be an integer");
 
-  return ovl (octave_wait::termsig (status));
+  return ovl (octave::sys::wtermsig (status));
 }
 
 DEFUNX ("WCOREDUMP", FWCOREDUMP, args, ,
@@ -1218,7 +1218,7 @@
 
   int status = args(0).xint_value ("WCOREDUMP: STATUS must be an integer");
 
-  return ovl (octave_wait::coredump (status));
+  return ovl (octave::sys::wcoredump (status));
 }
 
 DEFUNX ("WIFSTOPPED", FWIFSTOPPED, args, ,
@@ -1237,7 +1237,7 @@
 
   int status = args(0).xint_value ("WIFSTOPPED: STATUS must be an integer");
 
-  return ovl (octave_wait::ifstopped (status));
+  return ovl (octave::sys::wifstopped (status));
 }
 
 DEFUNX ("WSTOPSIG", FWSTOPSIG, args, ,
@@ -1255,7 +1255,7 @@
 
   int status = args(0).xint_value ("WSTOPSIG: STATUS must be an integer");
 
-  return ovl (octave_wait::stopsig (status));
+  return ovl (octave::sys::wstopsig (status));
 }
 
 DEFUNX ("WIFCONTINUED", FWIFCONTINUED, args, ,
@@ -1271,7 +1271,7 @@
 
   int status = args(0).xint_value ("WIFCONTINUED: STATUS must be an integer");
 
-  return ovl (octave_wait::ifcontinued (status));
+  return ovl (octave::sys::wifcontinued (status));
 }
 
 DEFUNX ("canonicalize_file_name", Fcanonicalize_file_name, args, ,
@@ -1304,7 +1304,7 @@
   return octave_value (val);
 }
 
-DEFUN (F_DUPFD, args, ,
+DEFUNX ("F_DUPFD", FF_DUPFD, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {} {} F_DUPFD ()\n\
 Return the numerical value to pass to @code{fcntl} to return\n\
@@ -1320,7 +1320,7 @@
   return const_value (args, val);
 }
 
-DEFUN (F_GETFD, args, ,
+DEFUNX ("F_GETFD", FF_GETFD, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {} {} F_GETFD ()\n\
 Return the numerical value to pass to @code{fcntl} to return\n\
@@ -1336,7 +1336,7 @@
   return const_value (args, val);
 }
 
-DEFUN (F_GETFL, args, ,
+DEFUNX ("F_GETFL", FF_GETFL, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {} {} F_GETFL ()\n\
 Return the numerical value to pass to @code{fcntl} to return\n\
@@ -1352,7 +1352,7 @@
   return const_value (args, val);
 }
 
-DEFUN (F_SETFD, args, ,
+DEFUNX ("F_SETFD", FF_SETFD, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {} {} F_SETFD ()\n\
 Return the numerical value to pass to @code{fcntl} to set the file\n\
@@ -1368,7 +1368,7 @@
   return const_value (args, val);
 }
 
-DEFUN (F_SETFL, args, ,
+DEFUNX ("F_SETFL", FF_SETFL, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {} {} F_SETFL ()\n\
 Return the numerical value to pass to @code{fcntl} to set the file\n\
@@ -1384,7 +1384,7 @@
   return const_value (args, val);
 }
 
-DEFUN (O_APPEND, args, ,
+DEFUNX ("O_APPEND", FO_APPEND, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {} {} O_APPEND ()\n\
 Return the numerical value of the file status flag that may be\n\
@@ -1401,7 +1401,7 @@
   return const_value (args, val);
 }
 
-DEFUN (O_ASYNC, args, ,
+DEFUNX ("O_ASYNC", FO_ASYNC, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {} {} O_ASYNC ()\n\
 Return the numerical value of the file status flag that may be\n\
@@ -1417,7 +1417,7 @@
   return const_value (args, val);
 }
 
-DEFUN (O_CREAT, args, ,
+DEFUNX ("O_CREAT", FO_CREAT, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {} {} O_CREAT ()\n\
 Return the numerical value of the file status flag that may be\n\
@@ -1434,7 +1434,7 @@
   return const_value (args, val);
 }
 
-DEFUN (O_EXCL, args, ,
+DEFUNX ("O_EXCL", FO_EXCL, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {} {} O_EXCL ()\n\
 Return the numerical value of the file status flag that may be\n\
@@ -1450,7 +1450,7 @@
   return const_value (args, val);
 }
 
-DEFUN (O_NONBLOCK, args, ,
+DEFUNX ("O_NONBLOCK", FO_NONBLOCK, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {} {} O_NONBLOCK ()\n\
 Return the numerical value of the file status flag that may be\n\
@@ -1467,7 +1467,7 @@
   return const_value (args, val);
 }
 
-DEFUN (O_RDONLY, args, ,
+DEFUNX ("O_RDONLY", FO_RDONLY, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {} {} O_RDONLY ()\n\
 Return the numerical value of the file status flag that may be\n\
@@ -1483,7 +1483,7 @@
   return const_value (args, val);
 }
 
-DEFUN (O_RDWR, args, ,
+DEFUNX ("O_RDWR", FO_RDWR, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {} {} O_RDWR ()\n\
 Return the numerical value of the file status flag that may be\n\
@@ -1500,7 +1500,7 @@
   return const_value (args, val);
 }
 
-DEFUN (O_SYNC, args, ,
+DEFUNX ("O_SYNC", FO_SYNC, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {} {} O_SYNC ()\n\
 Return the numerical value of the file status flag that may be\n\
@@ -1517,7 +1517,7 @@
   return const_value (args, val);
 }
 
-DEFUN (O_TRUNC, args, ,
+DEFUNX ("O_TRUNC", FO_TRUNC, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {} {} O_TRUNC ()\n\
 Return the numerical value of the file status flag that may be\n\
@@ -1534,7 +1534,7 @@
   return const_value (args, val);
 }
 
-DEFUN (O_WRONLY, args, ,
+DEFUNX ("O_WRONLY", FO_WRONLY, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {} {} O_WRONLY ()\n\
 Return the numerical value of the file status flag that may be\n\
@@ -1550,10 +1550,6 @@
   return const_value (args, val);
 }
 
-#if ! defined (WNOHANG)
-#define WNOHANG 0
-#endif
-
 DEFUNX ("WNOHANG", FWNOHANG, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {} {} WNOHANG ()\n\
@@ -1563,13 +1559,9 @@
 @seealso{waitpid, WUNTRACED, WCONTINUE}\n\
 @end deftypefn")
 {
-  return const_value (args, WNOHANG);
+  return const_value (args, octave::sys::wnohang ());
 }
 
-#if ! defined (WUNTRACED)
-#define WUNTRACED 0
-#endif
-
 DEFUNX ("WUNTRACED", FWUNTRACED, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {} {} WUNTRACED ()\n\
@@ -1579,13 +1571,9 @@
 @seealso{waitpid, WNOHANG, WCONTINUE}\n\
 @end deftypefn")
 {
-  return const_value (args, WUNTRACED);
+  return const_value (args, octave::sys::wuntraced ());
 }
 
-#if ! defined (WCONTINUE)
-#define WCONTINUE 0
-#endif
-
 DEFUNX ("WCONTINUE", FWCONTINUE, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {} {} WCONTINUE ()\n\
@@ -1595,5 +1583,5 @@
 @seealso{waitpid, WNOHANG, WUNTRACED}\n\
 @end deftypefn")
 {
-  return const_value (args, WCONTINUE);
+  return const_value (args, octave::sys::wcontinue ());
 }
--- a/libinterp/corefcn/toplev.cc	Wed Jun 15 16:41:02 2016 -0400
+++ b/libinterp/corefcn/toplev.cc	Thu Jun 16 01:00:20 2016 -0400
@@ -43,6 +43,7 @@
 #include "oct-env.h"
 #include "oct-fftw.h"
 #include "oct-locbuf.h"
+#include "oct-syscalls.h"
 #include "quit.h"
 #include "singleton-cleanup.h"
 #include "str-vec.h"
@@ -72,7 +73,6 @@
 #include "pt-stmt.h"
 #include "sighandlers.h"
 #include "sysdep.h"
-#include "syswait.h"
 #include "toplev.h"
 #include "unwind-prot.h"
 #include "utils.h"
@@ -1031,8 +1031,8 @@
 
   int cmd_status = cmd->close ();
 
-  if (octave_wait::ifexited (cmd_status))
-    cmd_status = octave_wait::exitstatus (cmd_status);
+  if (octave::sys::wifexited (cmd_status))
+    cmd_status = octave::sys::wexitstatus (cmd_status);
   else
     cmd_status = 127;
 
@@ -1190,8 +1190,8 @@
       // status of the command.  Otherwise, return 127 as a
       // failure code.
 
-      if (octave_wait::ifexited (status))
-        status = octave_wait::exitstatus (status);
+      if (octave::sys::wifexited (status))
+        status = octave::sys::wexitstatus (status);
 
       retval(0) = status;
     }
--- a/liboctave/system/module.mk	Wed Jun 15 16:41:02 2016 -0400
+++ b/liboctave/system/module.mk	Thu Jun 16 01:00:20 2016 -0400
@@ -11,9 +11,6 @@
   liboctave/system/oct-time.h \
   liboctave/system/oct-uname.h
 
-NOINSTALL_SYSTEM_INC = \
-  liboctave/system/syswait.h
-
 SYSTEM_SRC = \
   liboctave/system/dir-ops.cc \
   liboctave/system/file-ops.cc \
@@ -25,8 +22,7 @@
   liboctave/system/oct-passwd.cc \
   liboctave/system/oct-syscalls.cc \
   liboctave/system/oct-time.cc \
-  liboctave/system/oct-uname.cc \
-  $(NOINSTALL_SYSTEM_INC)
+  liboctave/system/oct-uname.cc
 
 noinst_LTLIBRARIES += liboctave/system/libsystem.la
 
--- a/liboctave/system/oct-syscalls.cc	Wed Jun 15 16:41:02 2016 -0400
+++ b/liboctave/system/oct-syscalls.cc	Thu Jun 16 01:00:20 2016 -0400
@@ -40,6 +40,7 @@
 #include "octave-popen2.h"
 #include "str-vec.h"
 #include "unistd-wrappers.h"
+#include "wait-wrappers.h"
 
 #define NOT_SUPPORTED(nm) \
   nm ": not supported on this system"
@@ -216,19 +217,81 @@
       pid_t retval = -1;
       msg = "";
 
-#if defined (HAVE_WAITPID)
-      retval = ::octave_waitpid (pid, status, options);
+      retval = octave_waitpid_wrapper (pid, status, options);
 
       if (retval < 0)
         msg = gnulib::strerror (errno);
-#else
-      msg = NOT_SUPPORTED ("waitpid");
-#endif
 
       return retval;
     }
 
     int
+    wcontinue (void)
+    {
+      return octave_wcontinue_wrapper ();
+    }
+
+    int
+    wcoredump (int status)
+    {
+      return octave_wcoredump_wrapper (status);
+    }
+
+    bool
+    wifcontinued (int status)
+    {
+      return octave_wifcontinued_wrapper (status);
+    }
+
+    bool
+    wifexited (int status)
+    {
+      return octave_wifexited_wrapper (status);
+    }
+
+    bool
+    wifsignaled (int status)
+    {
+      return octave_wifsignaled_wrapper (status);
+    }
+
+    bool
+    wifstopped (int status)
+    {
+      return octave_wifstopped_wrapper (status);
+    }
+
+    int
+    wexitstatus (int status)
+    {
+      return octave_wexitstatus_wrapper (status);
+    }
+
+    int
+    wnohang (void)
+    {
+      return octave_wnohang_wrapper ();
+    }
+
+    int
+    wstopsig (int status)
+    {
+      return octave_wstopsig_wrapper (status);
+    }
+
+    int
+    wtermsig (int status)
+    {
+      return octave_wtermsig_wrapper (status);
+    }
+
+    int
+    wuntraced (void)
+    {
+      return octave_wuntraced_wrapper ();
+    }
+
+    int
     kill (pid_t pid, int sig)
     {
       std::string msg;
--- a/liboctave/system/oct-syscalls.h	Wed Jun 15 16:41:02 2016 -0400
+++ b/liboctave/system/oct-syscalls.h	Thu Jun 16 01:00:20 2016 -0400
@@ -66,6 +66,28 @@
     extern OCTAVE_API pid_t waitpid (pid_t, int *status, int);
     extern OCTAVE_API pid_t waitpid (pid_t, int *status, int, std::string&);
 
+    extern OCTAVE_API int wcontinue (void);
+
+    extern OCTAVE_API int wcoredump (int status);
+
+    extern OCTAVE_API bool wifcontinued (int status);
+
+    extern OCTAVE_API bool wifexited (int status);
+
+    extern OCTAVE_API bool wifsignaled (int status);
+
+    extern OCTAVE_API bool wifstopped (int status);
+
+    extern OCTAVE_API int wexitstatus (int status);
+
+    extern OCTAVE_API int wnohang (void);
+
+    extern OCTAVE_API int wstopsig (int status);
+
+    extern OCTAVE_API int wtermsig (int status);
+    
+    extern OCTAVE_API int wuntraced (void);
+
     extern OCTAVE_API int kill (pid_t, int);
     extern OCTAVE_API int kill (pid_t, int, std::string&);
 
--- a/liboctave/system/syswait.h	Wed Jun 15 16:41:02 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
-
-Copyright (C) 1996-2015 John W. Eaton
-
-This file is part of Octave.
-
-Octave is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 3 of the License, or (at your
-option) any later version.
-
-Octave is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with Octave; see the file COPYING.  If not, see
-<http://www.gnu.org/licenses/>.
-
-*/
-
-#if ! defined (octave_syswait_h)
-#define octave_syswait_h 1
-
-#include "octave-config.h"
-
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
-/* This mess suggested by the autoconf manual.  */
-
-#include <sys/types.h>
-
-#if defined HAVE_SYS_WAIT_H
-#  include <sys/wait.h>
-#endif
-
-#if ! defined (WIFEXITED)
-#  define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
-#endif
-
-#if ! defined (WEXITSTATUS)
-#  define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
-#endif
-
-#if ! defined (WIFSIGNALLED)
-#  define WIFSIGNALLED(stat_val) \
-          (((stat_val) & 0177) != 0177 && ((stat_val) & 0177) != 0)
-#endif
-
-#if defined (__MINGW32__) || defined (_MSC_VER)
-#  define HAVE_WAITPID 1
-#  include <process.h>
-#  define WAITPID(a, b, c) _cwait (b, a, c)
-/* Action argument is ignored for _cwait, so arbitrary definition.  */
-#  define WNOHANG 0
-#else
-#  define WAITPID(a, b, c) waitpid (a, b, c)
-#endif
-
-#if defined (__cplusplus)
-}
-#endif
-
-#endif
--- a/liboctave/util/lo-cutils.c	Wed Jun 15 16:41:02 2016 -0400
+++ b/liboctave/util/lo-cutils.c	Thu Jun 16 01:00:20 2016 -0400
@@ -24,8 +24,6 @@
 #  include "config.h"
 #endif
 
-#include "lo-error.h"
-
 /* This gives us a better chance of finding a prototype for strptime
    on some systems.  */
 
@@ -38,7 +36,7 @@
 #include <time.h>
 
 #include "lo-cutils.h"
-#include "syswait.h"
+#include "lo-error.h"
 
 OCTAVE_API void
 octave_qsort (void *base, size_t n, size_t size,
@@ -58,129 +56,3 @@
 {
   return strncasecmp (s1, s2, n);
 }
-
-OCTAVE_API pid_t
-octave_waitpid (pid_t pid, int *status, int options)
-{
-  return WAITPID (pid, status, options);
-}
-
-static inline void
-warn_missing_wait_macro (const char *id, int status)
-{
-  (*current_liboctave_warning_handler)
-    ("%s always returns false in this version of Octave; status = %d",
-     id, status);
-}
-
-OCTAVE_API int
-octave_wifexited (int status)
-{
-  int retval = 0;
-
-#if defined (WIFEXITED)
-  retval = WIFEXITED (status);
-#else
-  warn_missing_wait_macro ("WIFEXITED", status);
-#endif
-
-  return retval;
-}
-
-OCTAVE_API int
-octave_wexitstatus (int status)
-{
-  int retval = 0;
-
-#if defined (WEXITSTATUS)
-  retval = WEXITSTATUS (status);
-#else
-  warn_missing_wait_macro ("WEXITSTATUS", status);
-#endif
-
-  return retval;
-}
-
-OCTAVE_API int
-octave_wifsignaled (int status)
-{
-  int retval = 0;
-
-#if defined (WIFSIGNALED)
-  retval = WIFSIGNALED (status);
-#else
-  warn_missing_wait_macro ("WIFSIGNALED", status);
-#endif
-
-  return retval;
-}
-
-OCTAVE_API int
-octave_wtermsig (int status)
-{
-  int retval = 0;
-
-#if defined (WTERMSIG)
-  retval = WTERMSIG (status);
-#else
-  warn_missing_wait_macro ("WTERMSIG", status);
-#endif
-
-  return retval;
-}
-
-OCTAVE_API int
-octave_wcoredump (int status)
-{
-  int retval = 0;
-
-#if defined (WCOREDUMP)
-  retval = WCOREDUMP (status);
-#else
-  warn_missing_wait_macro ("WCOREDUMP", status);
-#endif
-
-  return retval;
-}
-
-OCTAVE_API int
-octave_wifstopped (int status)
-{
-  int retval = 0;
-
-#if defined (WIFSTOPPED)
-  retval = WIFSTOPPED (status);
-#else
-  warn_missing_wait_macro ("WIFSTOPPED", status);
-#endif
-
-  return retval;
-}
-
-OCTAVE_API int
-octave_wstopsig (int status)
-{
-  int retval = 0;
-
-#if defined (WSTOPSIG)
-  retval = WSTOPSIG (status);
-#else
-  warn_missing_wait_macro ("WSTOPSIG", status);
-#endif
-
-  return retval;
-}
-
-OCTAVE_API int
-octave_wifcontinued (int status)
-{
-  int retval = 0;
-
-#if defined (WIFCONTINUED)
-  retval = WIFCONTINUED (status);
-#else
-  warn_missing_wait_macro ("WIFCONTINUED", status);
-#endif
-
-  return retval;
-}
--- a/liboctave/util/lo-cutils.h	Wed Jun 15 16:41:02 2016 -0400
+++ b/liboctave/util/lo-cutils.h	Thu Jun 16 01:00:20 2016 -0400
@@ -41,18 +41,6 @@
 OCTAVE_API int
 octave_strncasecmp (const char *s1, const char *s2, size_t n);
 
-OCTAVE_API pid_t
-octave_waitpid (pid_t pid, int *status, int options);
-
-OCTAVE_API int octave_wifexited (int status);
-OCTAVE_API int octave_wexitstatus (int status);
-OCTAVE_API int octave_wifsignaled (int status);
-OCTAVE_API int octave_wtermsig (int status);
-OCTAVE_API int octave_wcoredump (int status);
-OCTAVE_API int octave_wifstopped (int status);
-OCTAVE_API int octave_wstopsig (int status);
-OCTAVE_API int octave_wifcontinued (int status);
-
 #if defined (__cplusplus)
 }
 #endif
--- a/liboctave/util/lo-utils.h	Wed Jun 15 16:41:02 2016 -0400
+++ b/liboctave/util/lo-utils.h	Thu Jun 16 01:00:20 2016 -0400
@@ -137,52 +137,4 @@
 extern OCTAVE_API void
 octave_write_float_complex (std::ostream& os, const FloatComplex& cval);
 
-// Maybe this is overkill, but it allos
-
-class
-octave_wait
-{
-public:
-
-  static bool ifexited (int status)
-  {
-    return octave_wifexited (status);
-  }
-
-  static int exitstatus (int status)
-  {
-    return octave_wexitstatus (status);
-  }
-
-  static bool ifsignaled (int status)
-  {
-    return octave_wifsignaled (status);
-  }
-
-  static int termsig (int status)
-  {
-    return octave_wtermsig (status);
-  }
-
-  static bool coredump (int status)
-  {
-    return octave_wcoredump (status);
-  }
-
-  static bool ifstopped (int status)
-  {
-    return octave_wifstopped (status);
-  }
-
-  static int stopsig (int status)
-  {
-    return octave_wstopsig (status);
-  }
-
-  static bool ifcontinued (int status)
-  {
-    return octave_wifcontinued (status);
-  }
-};
-
 #endif
--- a/liboctave/wrappers/module.mk	Wed Jun 15 16:41:02 2016 -0400
+++ b/liboctave/wrappers/module.mk	Thu Jun 16 01:00:20 2016 -0400
@@ -21,7 +21,8 @@
   liboctave/wrappers/unistd-wrappers.h \
   liboctave/wrappers/unsetenv-wrapper.h \
   liboctave/wrappers/vasprintf-wrapper.h \
-  liboctave/wrappers/wait-for-input.h
+  liboctave/wrappers/wait-for-input.h \
+  liboctave/wrappers/wait-wrappers.h
 
 WRAPPERS_SRC = \
   liboctave/wrappers/areadlink-wrapper.c \
@@ -47,6 +48,7 @@
   liboctave/wrappers/unsetenv-wrapper.c \
   liboctave/wrappers/vasprintf-wrapper.c \
   liboctave/wrappers/wait-for-input.c \
+  liboctave/wrappers/wait-wrappers.c \
   $(NOINSTALL_WRAPPERS_INC)
 
 noinst_LTLIBRARIES += liboctave/wrappers/libwrappers.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboctave/wrappers/wait-wrappers.c	Thu Jun 16 01:00:20 2016 -0400
@@ -0,0 +1,119 @@
+/*
+
+Copyright (C) 2016 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+// These functions may be provided by gnulib.  We don't include gnulib
+// headers directly in Octave's C++ source files to avoid problems that
+// may be caused by the way that gnulib overrides standard library
+// functions.
+
+#if defined (HAVE_CONFIG_H)
+#  include "config.h"
+#endif
+
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include "wait-wrappers.h"
+
+#if ! defined (WCONTINUE)
+#  define WCONTINUE 0
+#endif
+
+#if ! defined (WNOHANG)
+#  define WNOHANG 0
+#endif
+
+#if ! defined (WUNTRACED)
+#  define WUNTRACED 0
+#endif
+
+pid_t
+octave_waitpid_wrapper (pid_t pid, int *statusp, int options)
+{
+  return waitpid (pid, statusp, options);
+}
+
+int
+octave_wcontinue_wrapper (void)
+{
+  return WCONTINUE;
+}
+
+int
+octave_wcoredump_wrapper (int status)
+{
+  return WCOREDUMP (status);
+}
+
+bool
+octave_wifcontinued_wrapper (int status)
+{
+  return WIFCONTINUED (status);
+}
+
+bool
+octave_wifexited_wrapper (int status)
+{
+  return WIFEXITED (status);
+}
+
+bool
+octave_wifsignaled_wrapper (int status)
+{
+  return WIFSIGNALED (status);
+}
+
+bool
+octave_wifstopped_wrapper (int status)
+{
+  return WIFSTOPPED (status);
+}
+
+int
+octave_wexitstatus_wrapper (int status)
+{
+  return WEXITSTATUS (status);
+}
+
+int
+octave_wnohang_wrapper (void)
+{
+  return WNOHANG;
+}
+
+int
+octave_wstopsig_wrapper (int status)
+{
+  return WSTOPSIG (status);
+}
+
+int
+octave_wtermsig_wrapper (int status)
+{
+  return WTERMSIG (status);
+}
+
+int
+octave_wuntraced_wrapper (void)
+{
+  return WUNTRACED;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboctave/wrappers/wait-wrappers.h	Thu Jun 16 01:00:20 2016 -0400
@@ -0,0 +1,64 @@
+/*
+
+Copyright (C) 2016 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+#if ! defined (octave_wait_wrappers_h)
+#define octave_wait_wrappers_h 1
+
+#include <sys/types.h>
+
+#if ! defined (__cplusplus)
+#  include <stdbool.h>
+#endif
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+extern pid_t octave_waitpid_wrapper (pid_t pid, int *statusp, int options);
+
+extern int octave_wcontinue_wrapper (void);
+
+extern int octave_wcoredump_wrapper (int status);
+
+extern bool octave_wifcontinued_wrapper (int status);
+
+extern bool octave_wifexited_wrapper (int status);
+
+extern bool octave_wifsignaled_wrapper (int status);
+
+extern bool octave_wifstopped_wrapper (int status);
+
+extern int octave_wexitstatus_wrapper (int status);
+
+extern int octave_wnohang_wrapper (void);
+  
+extern int octave_wstopsig_wrapper (int status);
+
+extern int octave_wtermsig_wrapper (int status);
+
+extern int octave_wuntraced_wrapper (void);
+
+#if defined __cplusplus
+}
+#endif
+
+#endif
--- a/src/main.in.cc	Wed Jun 15 16:41:02 2016 -0400
+++ b/src/main.in.cc	Thu Jun 16 01:00:20 2016 -0400
@@ -42,6 +42,8 @@
 #include <sys/types.h>
 #include <unistd.h>
 
+#include "wait-wrappers.h"
+
 #if ! defined (OCTAVE_VERSION)
 #  define OCTAVE_VERSION %OCTAVE_VERSION%
 #endif
@@ -69,10 +71,6 @@
 #include <signal.h>
 #include <fcntl.h>
 
-// This is a liboctave header, but it doesn't include any other Octave
-// headers or declare any functions that are defined in liboctave.
-#include "syswait.h"
-
 typedef void sig_handler (int);
 
 // Forward signals to the GUI process.
@@ -571,7 +569,7 @@
 
           while (true)
             {
-              WAITPID (gui_pid, &status, 0);
+              octave_waitpid_wrapper (gui_pid, &status, 0);
 
               if (caught_signal > 0)
                 {
@@ -581,15 +579,15 @@
 
                   kill (gui_pid, sig);
                 }
-              else if (WIFEXITED (status))
+              else if (octave_wifexited_wrapper (status))
                 {
-                  retval = WEXITSTATUS (status);
+                  retval = octave_wexitstatus_wrapper (status);
                   break;
                 }
-              else if (WIFSIGNALLED (status))
+              else if (octave_wifsignaled_wrapper (status))
                 {
                   std::cerr << "octave exited with signal "
-                            << WTERMSIG (status) << std::endl;
+                            << octave_wtermsig_wrapper (status) << std::endl;
                   break;
                 }
             }
--- a/src/module.mk	Wed Jun 15 16:41:02 2016 -0400
+++ b/src/module.mk	Thu Jun 16 01:00:20 2016 -0400
@@ -13,6 +13,7 @@
   -I$(srcdir)/liboctave/numeric \
   -I$(srcdir)/liboctave/system \
   -I$(srcdir)/liboctave/util \
+  -Iliboctave/wrappers -I$(srcdir)/liboctave/wrappers \
   -Ilibinterp -I$(srcdir)/libinterp \
   -Ilibinterp/corefcn -I$(srcdir)/libinterp/corefcn \
   -I$(srcdir)/src \
@@ -57,13 +58,15 @@
 
 OCTAVE_CORE_LIBS = \
   libinterp/liboctinterp.la \
-  liboctave/liboctave.la
+  liboctave/liboctave.la \
+  libgnu/libgnu.la
 
 nodist_src_octave_SOURCES = src/main.cc
 
 src_octave_SOURCES = src/display-available.c
 
 src_octave_LDADD = \
+  liboctave/wrappers/libwrappers.la \
   libgnu/libgnu.la \
   $(X11_LIBS) \
   $(CARBON_LIBS) \
@@ -135,7 +138,8 @@
 
 nodist_src_mkoctfile_SOURCES = src/mkoctfile.cc
 
-src_mkoctfile_LDADD = libgnu/libgnu.la $(LIBS)
+src_mkoctfile_LDADD = \
+  libgnu/libgnu.la $(LIBS)
 
 src_mkoctfile_CPPFLAGS = \
   $(SRC_DIR_CPPFLAGS) \