Page 1 of 1

stdout buffering with -script - mode

Posted: 2014-09-22T02:53:31-07:00
by chrisedwards
I've compiled Magick (IM7) for Windows 8 with standard options and no compile errors.

I'm trying to build a simple wrapper around magick.exe with Python subprocess.POpen and have been running into trouble with buffering of the script output, which I've isolated as being an issue with how magick.exe runs on windows.

Here's the python side of things:
http://stackoverflow.com/questions/2596 ... terminates

Essentially, when magick.exe output is being redirected it is buffering the output. Is there a flag I can set to flush stdout after magick writes to stdout? To use "-script -" effectively I need to be getting the stdout buffer back in a timely manner and can't wait for the buffer to fill.

Or if you have any other ideas I'm open to them.

Regards,

Chris

Re: stdout buffering with -script - mode

Posted: 2014-09-22T03:49:20-07:00
by chrisedwards
Ok. For now I've disabled the buffer with:
setbuf(stdout, NULL);

Compiling now and will test it out.

Ideally a command should always flush() when it's done, since there would be some performance gains to letting the buffer exist if the output is large.
Otherwise it'd be be nice to be able to flush manually in -script mode, so one could send:

-print %[*] -print [EOC] -flush

(where [EOC] is an end of command delimiter used by receiving program to identify when a command has finished returning)

And you'd be guaranteed to have an empty buffer after the flush command.

Re: stdout buffering with -script - mode

Posted: 2014-09-22T04:04:55-07:00
by magick
We'll add a patch to IMv6 / IMv7 to flush standard out after a command completes. Thanks for the suggestion.

Re: stdout buffering with -script - mode

Posted: 2014-09-22T04:14:07-07:00
by chrisedwards
Thanks.