From 94cd9ac3867305184f310dbf411729c59897c2c5 Mon Sep 17 00:00:00 2001 From: Matthias Dahl Date: Tue, 24 Oct 2017 15:55:53 +0200 Subject: [PATCH 1/2] Add process output read accounting This tracks the bytes read from a process's stdin which is not used anywhere yet but required for follow-up work. * src/process.c (read_process_output): Track bytes read from a process. * src/process.h (struct Lisp_Process): Add infd_num_bytes_read to track bytes read from a process. --- src/process.c | 4 ++++ src/process.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/process.c b/src/process.c index fc46e74332..ab023457bd 100644 --- a/src/process.c +++ b/src/process.c @@ -5886,6 +5886,10 @@ read_process_output (Lisp_Object proc, int channel) nbytes += buffered && nbytes <= 0; } + /* Don't count carryover as those bytes have already been count by + a previous iteration. */ + p->infd_num_bytes_read += nbytes; + p->decoding_carryover = 0; /* At this point, NBYTES holds number of bytes just received diff --git a/src/process.h b/src/process.h index 5670f44736..96c19fcf81 100644 --- a/src/process.h +++ b/src/process.h @@ -129,6 +129,8 @@ struct Lisp_Process pid_t pid; /* Descriptor by which we read from this process. */ int infd; + /* Byte-count modulo (UINTMAX_MAX + 1) for process output read from `infd'. */ + uintmax_t infd_num_bytes_read; /* Descriptor by which we write to this process. */ int outfd; /* Descriptors that were created for this process and that need -- 2.15.0