From bug-octave-request at bevo dot che dot wisc dot edu Thu Sep 23 19:59:10 1999 Subject: Re: Cleanup after fork From: "John W. Eaton" To: aking at math dot arizona dot edu Cc: bug-octave at bevo dot che dot wisc dot edu Date: Thu, 23 Sep 1999 19:58:02 -0500 (CDT) On 23-Sep-1999, Aaron King wrote: | Sorry, I should have said "asynchronous mode" instead of | "synchronous". Try this: | | x = (0:0.01:2*pi)'; | plot(x, sin(x)); | system("ls", 1, "async"); | replot | | gnuplot> pl "/tmp/oct-11267aaa" t "line 1" | ^ | can't read data file "/tmp/oct-11267aaa" | line 0: (No such file or directory) OK, I see the problem now. | The temporary file (in this case in /tmp) has been deleted, not when | one program is replaced by another (using exec) but when that second | program exits. I'm imagining an option (set in the .octaverc file, | for example), which when = 0 prevents the cleanup from being | registered with atexit. I don't think an option is needed, because this just seems like wrong behavior to me. Here is a patch to try. Your line numbers will probably be different. Obviously, this will only work on systems with /bin/sh, so eventually some other fix needs to be found. Thanks, jwe Thu Sep 23 19:49:36 1999 John W. Eaton * toplev.cc (Fsystem): For async case, use execl instead of system, avoiding the need to exit after executing the subprocess. *** octave-2.0.14/src/toplev.cc Tue Nov 17 14:33:38 1998 --- src/toplev.cc Thu Sep 23 19:43:52 1999 *************** *** 842,850 **** error ("system: fork failed -- can't create child process"); else if (pid == 0) { ! system (cmd_str.c_str ()); ! exit (0); ! retval(0) = 0.0; } else retval(0) = (double) pid; --- 821,829 ---- error ("system: fork failed -- can't create child process"); else if (pid == 0) { ! execl ("/bin/sh", "sh", "-c", cmd_str.c_str (), 0); ! ! panic_impossible (); } else retval(0) = (double) pid; --------------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. To ensure that development continues, see www.che.wisc.edu/octave/giftform.html Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html ---------------------------------------------------------------------