[Intel-gfx] [i-g-t PATCH 1/4] lib/igt_core: Add igt_exec helpers
Abdiel Janulgue
abdiel.janulgue at linux.intel.com
Wed May 10 12:10:16 UTC 2017
On 09.05.2017 13:18, Petri Latvala wrote:
snip 8< -----
>> + memset(buf, 0, sizeof(buf));
>> + while (read(current->read_fd, buf, sizeof(buf)) > 0) {
>> + if (current->redirected) {
>> + if (!unredirect_output(current))
>> + return -1;
>> + }
>> + igt_log(IGT_LOG_DOMAIN, current->log_level,
>> + "[cmd] %s", buf);
>> + memset(buf, 0, sizeof(buf));
>> + }
>> + close(current->read_fd);
>> + }
>
>
> Unredirect_output calls for both pipes need to be called on all exit
> paths.
>
> In redirect_output you set only the read fd of the pipe() pair to
> O_NONBLOCK. That will make the executed command block on its writes
> indefinitely if it prints more than whatsitnow, 64kB?
> the
In case the stream output is more than the pipe buf, the read loop above
would just unblock the rest of the entries. From pipe(2) page:
"Data written to the write end of the pipe is buffered
by the kernel until it is read from the read end of the pipe."
Worked well when I tried it with igt_exec("../tools/intel_reg dump")
which dumps a screenfull of info.
More information about the Intel-gfx
mailing list