pipeProcess, interactions with stderr ... I am missing something here
Ali Çehreli
acehreli at yahoo.com
Mon Aug 30 16:51:12 UTC 2021
On 8/30/21 9:35 AM, james.p.leblanc wrote:
> D-ers,
>
> I am attempting to use pipeProcess for interacting with an external
> process.
> My simplified routine can work somewhat. But, trying to print any
messages
> that process writes to stderr yields the message:
>
> (master) gnuplot > gnuplot_example
> **core.exception.InvalidMemoryOperationError at src/core/exception.d(647):
> Invalid memory operation**
That error almost always means you are allocating memory in a
destructor, which sometimes is presumably due to using parts of your
object that have already been finalized by the GC. (Or, the GC has
already been terminated? I am not sure.)
In this case, converting your ~this to a named function solves the issue:
// Was: ~this()
void close() {
// ...
}
// ...
auto gp = new Gnuplot();
scope (exit) {
gp.close();
}
Ali
More information about the Digitalmars-d-learn
mailing list