stdout buffering with -script - mode

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
chrisedwards
Posts: 5
Joined: 2014-09-22T02:48:01-07:00
Authentication code: 6789

stdout buffering with -script - mode

Post 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
chrisedwards
Posts: 5
Joined: 2014-09-22T02:48:01-07:00
Authentication code: 6789

Re: stdout buffering with -script - mode

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: stdout buffering with -script - mode

Post by magick »

We'll add a patch to IMv6 / IMv7 to flush standard out after a command completes. Thanks for the suggestion.
chrisedwards
Posts: 5
Joined: 2014-09-22T02:48:01-07:00
Authentication code: 6789

Re: stdout buffering with -script - mode

Post by chrisedwards »

Thanks.
Post Reply