Mercurial > hg > octave-terminal
changeset 3147:894d516b4a00
[project @ 1998-02-06 06:00:08 by jwe]
author | jwe |
---|---|
date | Fri, 06 Feb 1998 06:00:10 +0000 |
parents | 3d5aefef14e2 |
children | 8cdcb8945695 |
files | ChangeLog config.h.bot configure.in liboctave/ChangeLog liboctave/oct-syscalls.cc liboctave/oct-syscalls.h src/ChangeLog src/dirfns.cc src/oct-procbuf.cc src/syscalls.cc src/toplev.cc src/version.h |
diffstat | 12 files changed, 128 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Feb 5 03:04:09 1998 John W. Eaton <jwe@bevo.che.wisc.edu> + + * configure.in: Check for vfork. + + * config.h.bot (X_CAST): New macro. + Wed Feb 4 01:42:50 1998 John W. Eaton <jwe@bevo.che.wisc.edu> * aclocal.m4 (OCTAVE_FLIBS): If ld_run_path is not absolute, kill it.
--- a/config.h.bot +++ b/config.h.bot @@ -15,6 +15,8 @@ #define STATIC_CAST(T, E) (T) (E) +#define X_CAST(T, E) (T) (E) + #define HEAVYWEIGHT_INDEXING 1 #define WITH_KPATHSEARCH 1
--- a/configure.in +++ b/configure.in @@ -21,7 +21,7 @@ ### Software Foundation, 59 Temple Place - Suite 330, Boston, MA ### 02111-1307, USA. -AC_REVISION($Revision: 1.296 $) +AC_REVISION($Revision: 1.297 $) AC_PREREQ(2.9) AC_INIT(src/octave.cc) AC_CONFIG_HEADER(config.h) @@ -693,8 +693,8 @@ gettimeofday getuid getwd lstat memmove mkdir mkfifo on_exit pipe \ putenv rename rindex rmdir setgrent setpwent setvbuf sigaction \ sigpending sigprocmask sigsuspend stat strcasecmp strdup strerror \ - stricmp strncasecmp strnicmp tempnam umask unlink usleep vfprintf \ - vsprintf waitpid) + stricmp strncasecmp strnicmp tempnam umask unlink usleep vfork \ + vfprintf vsprintf waitpid) OCTAVE_SMART_PUTENV
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,5 +1,7 @@ Thu Feb 5 02:12:38 1998 John W. Eaton <jwe@bevo.che.wisc.edu> + * oct-syscalls.cc (octave_syscalls::vfork): New function. + * lo-specfun.cc: Don't include dbleBessel.h. * Makefile.in (INCLUDES): Delete oct-math.h from the list.
--- a/liboctave/oct-syscalls.cc +++ b/liboctave/oct-syscalls.cc @@ -148,6 +148,27 @@ } pid_t +octave_syscalls::vfork (string& msg) +{ + pid_t status = -1; + +#if defined (HAVE_VFORK) || defined (HAVE_FORK) +#if defined (HAVE_VFORK) + status = ::vfork (); +#else + status = ::vfork (); +#endif + + if (status < 0) + msg = ::strerror (errno); +#else + msg = NOT_SUPPORTED ("vfork"); +#endif + + return status; +} + +pid_t octave_syscalls::getpgrp (string& msg) { pid_t status = -1;
--- a/liboctave/oct-syscalls.h +++ b/liboctave/oct-syscalls.h @@ -44,6 +44,7 @@ static int fcntl (int, int, long, string&); static pid_t fork (string&); + static pid_t vfork (string&); static pid_t getpgrp (string&);
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,13 @@ Thu Feb 5 02:27:18 1998 John W. Eaton <jwe@bevo.che.wisc.edu> + * dirfns.cc (Fls): If first attempt at reading process output + fails, sleep once and try again. + * toplev.cc (run_command_and_return_output): Likewise. + + * oct-procbuf.cc (octave_procbuf::open): Use vfork if it is available. + + * syscalls.cc (Fvfork): New function. + * ov-bool-mat.cc: Only declare assign function if CXX_NEW_FRIEND_TEMPLATE_DECL is not defined.
--- a/src/dirfns.cc +++ b/src/dirfns.cc @@ -155,11 +155,33 @@ unwind_protect::add (cleanup_iprocstream, cmd); + // XXX FIXME XXX -- sometimes, the subprocess hasn't written + // anything before we try to read from the procstream. The kluge + // below (simply waiting and trying again) is ugly, but it seems to + // work, at least most of the time. It could probably still fail if + // the subprocess hasn't started writing after the snooze. Isn't + // there a better way? If there is, you should also fix the code + // for the system function in toplev.cc. + if (cmd && *cmd) { - int ch; - while ((ch = cmd->get ()) != EOF) - octave_stdout << (char) ch; + char ch; + + if (cmd->get (ch)) + octave_stdout << ch; + else + { + cmd->clear (); + +#if defined (HAVE_USLEEP) + usleep (100); +#else + sleep (1); +#endif + } + + while (cmd->get (ch)) + octave_stdout << ch; } else error ("couldn't start process for ls!");
--- a/src/oct-procbuf.cc +++ b/src/oct-procbuf.cc @@ -55,7 +55,7 @@ int pipe_fds[2]; - int parent_end, child_end; + volatile int parent_end, child_end; if (is_open ()) return 0; @@ -74,7 +74,11 @@ child_end = pipe_fds[0]; } +#if defined HAVE_VFORK + proc_pid = vfork (); +#else proc_pid = fork (); +#endif if (proc_pid == 0) {
--- a/src/syscalls.cc +++ b/src/syscalls.cc @@ -285,6 +285,37 @@ return retval; } +DEFUN (vfork, args, , + "[PID, MSG] = vfork ()\n\ +\n\ +Create a copy of the current process.\n\ +\n\ +If successful, PID is either the process ID and you are in the parent,\n\ +or 0, and you are in the child. If PID is less than zero, an error\n\ +has occured, and MSG contains a system-dependent error message.") +{ + octave_value_list retval; + + retval(1) = string (); + retval(0) = -1.0; + + int nargin = args.length (); + + if (nargin == 0) + { + string msg; + + pid_t pid = octave_syscalls::vfork (msg); + + retval(0) = static_cast<double> (pid); + retval(1) = msg; + } + else + print_usage ("vfork"); + + return retval; +} + DEFUN (getpgrp, args, , "pgid = getpgrp (): return the process group id of the current process") {
--- a/src/toplev.cc +++ b/src/toplev.cc @@ -338,7 +338,30 @@ { ostrstream output_buf; + // XXX FIXME XXX -- sometimes, the subprocess hasn't written + // anything before we try to read from the procstream. The + // kluge below (simply waiting and trying again) is ugly, + // but it seems to work, at least most of the time. It + // could probably still fail if the subprocess hasn't + // started writing after the snooze. Isn't there a better + // way? If there is, you should also fix the code for the + // ls function in dirfns.cc. + char ch; + + if (cmd->get (ch)) + output_buf.put (ch); + else + { + cmd->clear (); + +#if defined (HAVE_USLEEP) + usleep (100); +#else + sleep (1); +#endif + } + while (cmd->get (ch)) output_buf.put (ch);