Re: [Fwd: Re: Last item on TODO list for mc before 4.6.1]



Leonard den Ottolander wrote:
When the viewer uses a filter, the filtering program (e.g. gzip) can return errors to stderr even before it completes. There was a function to drain and display the stderr output before the viewer starts. I removed it because it was problematic and Valgrind reported memory access problems. The whole code was a hack around popen. I believe the right solution would be to use our own popen replacement that would intercept strerr properly.

I had just written one two days ago:

int pipethrough(const char *command,
                const struct const_buffer *stdin_buf,
                /* out@*/ struct buffer *stdout_buf,
                /* out@*/ struct buffer *stderr_buf,
                /* out@*/ int *status);

It executes "command", which is a shell command, feeding the contents of "stdin_buf" into it and getting the output into two dynamically allocated buffers "stdout_buf" and "stderr_buf". After completion, the variable "status" contains the process exit status which can be examined using WIFEXITED and friends.

I am planning to write an extended version which does not simply fill buffers but uses callback routines whenever one of the streams (stdin, stdout, stderr) is ready.

Interested?

Roland



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]