Add non-blocking option for open() and splice_read() for avoiding block to read trace data of a guest from FIFO. If SIGINT comes to read/write processes from the parent process in the case where FIFO as a read I/F is assigned, then reading is normally blocked for splice_read(). So, we added nonblock option to open() and splice_read(). Signed-off-by: Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@xxxxxxxxxxx> --- trace-recorder.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/trace-recorder.c b/trace-recorder.c index 3b750e9..6577fe8 100644 --- a/trace-recorder.c +++ b/trace-recorder.c @@ -124,7 +124,7 @@ struct tracecmd_recorder *tracecmd_create_recorder_fd(int fd, int cpu) goto out_free; sprintf(path, "%s/per_cpu/cpu%d/trace_pipe_raw", tracing, cpu); - recorder->trace_fd = open(path, O_RDONLY); + recorder->trace_fd = open(path, O_RDONLY | O_NONBLOCK); if (recorder->trace_fd < 0) goto out_free; @@ -172,14 +172,17 @@ static long splice_data(struct tracecmd_recorder *recorder) long ret; ret = splice(recorder->trace_fd, NULL, recorder->brass[1], NULL, - recorder->page_size, 1 /* SPLICE_F_MOVE */); + recorder->page_size, SPLICE_F_MOVE | SPLICE_F_NONBLOCK); if (ret < 0) { - warning("recorder error in splice input"); - return -1; + if (errno != EAGAIN) { + warning("recorder error in splice input"); + return -1; + } + return 0; /* Buffer is empty */ } ret = splice(recorder->brass[0], NULL, recorder->fd, NULL, - recorder->page_size, 3 /* and NON_BLOCK */); + recorder->page_size, SPLICE_F_MOVE | SPLICE_F_NONBLOCK); if (ret < 0) { if (errno != EAGAIN) { warning("recorder error in splice output"); _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization