From bug-octave-request at bevo dot che dot wisc dot edu Thu Oct 8 14:06:47 1998 Subject: Unidentified subject! From: "John W. Eaton" To: john Cc: bug-octave at bevo dot che dot wisc dot edu Date: Thu, 8 Oct 1998 14:06:37 -0500 (CDT) On 5-Jul-1998, john wrote: | To: bug-octave at bevo dot che dot wisc dot edu | Cc: john at arrows dot demon dot co dot uk | Subject: closeplot failing after popen or system(xv,0,async) | | Bug report for Octave 2.0.13 configured for i586-pc-linux-gnulibc1 | | Description: | ----------- | | As previously reported, the sequence | | octave:1> sombrero(10) | octave:2> system("xv", 0, "async" ) ; | octave:3> closeplot | | causes octave to wait until the "xv" process completes.or | | Similarly, | | octave:1> sombrero(10) | octave:2> popen("sort", "w"); | octave:3> closeplot | | causes octave to wait, probably until the "sort" is terminated. Please try the following patch. This problem had me stumped for quite a while. I think all that is really required is the addition of sending "quit" to gnuplot before deleting the plot_stream object, but I think the other changes to the octave_procbuf and procstream classes are good too, just to clean things up a bit. Thanks, jwe Thu Oct 8 13:47:55 1998 John W. Eaton * oct-procbuf.h (octave_procbuf::wstatus): New data member. Initialize in constructors. (octave_procbuf::wait_status): New member function. * oct-procbuf.cc (octave_procbuf::sys_close): Use class data member wstatus, not local variable. * procstream.cc (procstreambase::close): Don't call sys_close directly. Get subprocess exit status by calling wait_status for our procbuf. * pt-plot.cc (close_plot_stream): Send "quit" command to gnuplot before deleting plot_stream. *** src/oct-procbuf.h~ Tue Apr 28 14:08:01 1998 --- src/oct-procbuf.h Wed Oct 7 13:29:32 1998 *************** *** 38,47 **** public: octave_procbuf (void) ! : filebuf (), proc_pid (-1), next (0) { } octave_procbuf (const char *command, int mode) ! : filebuf (), proc_pid (-1), next (0) { open (command, mode); } ~octave_procbuf (void) { close (); } --- 38,48 ---- public: octave_procbuf (void) ! : filebuf (), wstatus (-1), proc_pid (-1), next (0) { } octave_procbuf (const char *command, int mode) ! : filebuf (), wstatus (-1), proc_pid (-1), next (0) ! { open (command, mode); } ~octave_procbuf (void) { close (); } *************** *** 52,60 **** --- 53,65 ---- virtual int sys_close (void); + int wait_status (void) const { return wstatus; } + pid_t pid (void) { return proc_pid; } protected: + + int wstatus; pid_t proc_pid; *** src/oct-procbuf.cc~ Wed May 13 23:07:34 1998 --- src/oct-procbuf.cc Thu Oct 8 00:48:11 1998 *************** *** 146,153 **** { #if defined (HAVE_SYS_WAIT_H) - int wstatus; - pid_t wait_pid; int status = -1; --- 146,151 ---- *** src/procstream.h~ Sun Apr 28 04:00:07 1996 --- src/procstream.h Wed Oct 7 21:13:47 1998 *************** *** 78,86 **** ~iprocstream (void) { } void open (const char *name, int mode=ios::in) ! { ! procstreambase::open (name, mode); ! } private: --- 78,84 ---- ~iprocstream (void) { } void open (const char *name, int mode=ios::in) ! { procstreambase::open (name, mode); } private: *************** *** 102,110 **** ~oprocstream (void) { } void open (const char *name, int mode=ios::out) ! { ! procstreambase::open(name, mode); ! } private: --- 100,106 ---- ~oprocstream (void) { } void open (const char *name, int mode=ios::out) ! { procstreambase::open(name, mode); } private: *************** *** 123,135 **** procstream (const char *name, int mode) : procstreambase(name, mode) { } - ~procstream (void) { } void open (const char *name, int mode) ! { ! procstreambase::open(name, mode); ! } private: --- 119,128 ---- procstream (const char *name, int mode) : procstreambase(name, mode) { } ~procstream (void) { } void open (const char *name, int mode) ! { procstreambase::open(name, mode); } private: *** src/procstream.cc~ Sat Mar 2 19:45:43 1996 --- src/procstream.cc Wed Oct 7 13:30:14 1998 *************** *** 54,63 **** if (is_open ()) { - status = pb.sys_close (); - if (! pb.close ()) set (ios::failbit); } return status; --- 54,63 ---- if (is_open ()) { if (! pb.close ()) set (ios::failbit); + + status = pb.wait_status (); } return status; *** src/pt-plot.cc~ Wed Apr 15 01:19:36 1998 --- src/pt-plot.cc Thu Oct 8 13:49:10 1998 *************** *** 909,914 **** --- 909,915 ---- if (plot_stream) { + send_to_plot_stream ("\nquit\n"); delete plot_stream; plot_stream = 0; }