Menu

#393 Meshlab server: unbuffered stdout

v1.0_(example)
open
nobody
None
1
2014-05-14
2014-05-14
Maxime
No

Hi there,

stdout, outside an "interactive device", i.e., the console, is buffered by default.
See http://www.cplusplus.com/reference/cstdio/stdout/:
"If stdout is known to not refer to an interactive device, the stream is fully buffered. Otherwise, it is library-dependent whether the stream is line buffered or not buffered by default (see setvbuf)."

It means you can't follow the progress of meshlabserver in realtime when you spawn the meshlabserver process programmatically, as all the progress information will be outputed once the proces exit (or when the buffer is full, which can happen very late).

The fix is one line of code, to add before any I/O operation on stdout:

setvbuf(stdout, NULL, _IONBF, 0);

I've added it in mainserver.cpp, just after opening the main function, between line 502 and 503 of the current trunk version.

It would be great if that one line of code could be added by one of the maintainer of the project.

Thanks in advance!

Discussion


Log in to post a comment.