From owner-bug-octave at bevo dot che dot wisc dot edu Fri Jan 24 18:59:25 1997 Subject: Re: octave 2.0: popen2 bug From: Joao Cardoso To: bug-octave at bevo dot che dot wisc dot edu Date: Fri, 24 Jan 97 00:58:07 GMT John W. Eaton wrote: | From: "John W. Eaton" | To: jcardoso at inescn dot pt | Subject: octave 2.0: popen2 bug | | On 20-Dec-1996, Joao Cardoso wrote: | | : In my system popen2 is broken. Bellow is a run of the suggested | : help example. As soon as the write pipe to the process is closed, | : it starts writing to octave, but not to the read pipe: | : | : octave:380> [in, out, pid] = popen2 ("sort", "-nr"); | : octave:381> fputs (in, "these\n"); | : octave:382> fputs (in, "are\n"); | : octave:383> fputs (in, "some\n"); | : octave:384> fputs (in, "strings\n"); | : octave:385> fclose (in); | : these | : strings | : some | : are | | | I can't reproduce this problem on either a DEC Alpha running OSF/1 3.2 | or a Linux system. Here is what I see: | | octave:1> [in, out, pid] = popen2 ("sort", "-nr"); | octave:2> fputs (in, "these\n"); | octave:3> fputs (in, "are\n"); | octave:4> fputs (in, "some\n"); | octave:5> fputs (in, "strings\n"); | octave:6> fclose (in); | octave:7> fgetl (out) | ans = these | octave:8> fgetl (out) | ans = strings | octave:9> fgetl (out) | ans = some | octave:10> fgetl (out) | ans = are | octave:11> fgetl (out) | ans = -1 | | | Can you please try to debug this problem? I tried, but I did not succed. It's hard to debug a forked octave... I has even tried 'pstat', looking for open files, inodes,... but I giveup, as there are too many open files listed. The problem seems to be that the standard output of the forked octave is not correctly redirected to the standard input of the parent one. This propagate to the exec process. This can be seen in the output above. From the output, from what channel does octave receive the exec process output? stderr? How can I close it? If I open a file for writing in the child octave, and 'dup2' it to the standard output, the file output is OK. It is not a script error, so must be SCO again :( I will write to a file, then 'system', then read from file. Thanks, Joao -- Joao Cardoso, INESC | e-mail: jcardoso at inescn dot pt R. Jose Falcao 110 | tel: + 351 2 2094345 4000 Porto, Portugal | fax: + 351 2 2008487