From 94e0dc26f45e1a06881b016dd26446c43d339a4d 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' 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 nbytes_read to track bytes read from a process. --- src/process.c | 3 +++ src/process.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/process.c b/src/process.c index 2ec10b12ec..17fdf592ec 100644 --- a/src/process.c +++ b/src/process.c @@ -5889,6 +5889,9 @@ read_process_output (Lisp_Object proc, int channel) return nbytes; coding->mode |= CODING_MODE_LAST_BLOCK; } + + /* Ignore carryover, it's been added by a previous iteration already. */ + p->nbytes_read += nbytes; /* Now set NBYTES how many bytes we must decode. */ nbytes += carryover; diff --git a/src/process.h b/src/process.h index ab468b18c5..6464a8cc61 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 nbytes_read; /* Descriptor by which we write to this process. */ int outfd; /* Descriptors that were created for this process and that need -- 2.16.1