padding in arguments string array for popen2 or exec
Olaf Till
olaf.till at uni-jena.de
Mon Mar 2 05:04:14 CST 2009
Hi,
in Octave-3.0.3 (probably all versions >= 3.0) please consider the
following errors:
octave:1> [pdw, pdr, pid] = popen2 ("ssh", char ("localhost", "octave-3.0.2"))
pdw = 5
pdr = 6
pid = 11773
octave:2> ssh: localhost : Name or service not known
octave:2> exec ("ssh", char ("localhost", "octave-3.0.2"))
ssh: localhost : Name or service not known
olaf at olaf:~/devel/src/octave-3.0.3$
(Don't worry about my calling Octave version 3.0.2 with the passed
arguments, version 3.0.3 is not installed, but run in place with
./run-octave.)
Note the spaces in "localhost :" . Debugging indicates that the
"all_strings()" method returns the arguments padded (in
liboctave/oct-syscalls.cc(execvp)):
(gdb) print argv[0]
$4 = 0x97bd940 "ssh"
(gdb) print argv[1]
$5 = 0x97bda68 "localhost "
(gdb) print argv[2]
$6 = 0x97bda80 "octave-3.0.2"
(All but the first argv elements were filled in from a string_vector
returned by all_strings() in src/syscalls.cc(popen2) .)
In Octave-2.1.73, for which I have no locally-compiled binary
available for gdb, the problem does not occur:
octave2.1:1> [pdw, pdr, pid] = popen2 ("ssh", char ("localhost", "octave-3.0.2"))
pdw =
{
id = 3
name =
mode = w
arch = ieee_little_endian
status = open
}
pdr =
{
id = 6
name =
mode = r
arch = ieee_little_endian
status = open
}
pid = 11611
octave2.1:2>
octave2.1:2> warning: DEFAULT_LOADPATH is no longer a built-in variable; please read the NEWS file or type `news' for details
octave2.1:2>
although according to the source (despite an implementation of popen2
in an m-file) after all the all_strings() method is used in the same
way (for giving all but the first element of the sring_vector passed
to Octaves execvp) as in versions >= 3.0.
Olaf
More information about the Bug-octave
mailing list