Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Martin Schulte Newsgroups: gnu.bash.bug Subject: Re: Difference between EPOCHREALTIME and EPOCHSECONDS Date: Tue, 14 Apr 2020 19:43:34 +0200 Lines: 46 Approved: bug-bash@gnu.org Message-ID: References: <4ffdb354-3a55-e588-0d53-b170b6c0ca4f@case.edu> <20200414194334.b18fba820739b99e92c863be@schrader-schulte.de> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: usenet.stanford.edu 1586886227 1566 209.51.188.17 (14 Apr 2020 17:43:47 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org In-Reply-To: <4ffdb354-3a55-e588-0d53-b170b6c0ca4f@case.edu> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 51.15.128.4 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <20200414194334.b18fba820739b99e92c863be@schrader-schulte.de> X-Mailman-Original-References: <4ffdb354-3a55-e588-0d53-b170b6c0ca4f@case.edu> Xref: csiph.com gnu.bash.bug:16133 Hello Chet, hello Felix, hello all! > > Bash Version: 5.0 > > Patch Level: 16 > > Release Status: release > > > > Description: > > Integer part of $EPOCHREALTIME could increase more than 8000 > > microseconds before $EPOCHSECONDS > > It's the difference between time() and gettimeofday(). I didn't believe it ;-) but running time_gettimeofday.c: ==================== #include #include #include int main(int argc, char *argv[]) { struct timeval tv; time_t t; struct timespec sleep; sleep.tv_sec = 0; sleep.tv_nsec = 1000000; for (int i=0; i<1001; i++) { gettimeofday(&tv, NULL); t = time(NULL); printf("%d.%.6d %d %d\n", tv.tv_sec, tv.tv_usec, t, tv.tv_sec-t); nanosleep( &sleep, NULL ); } return 0; } with gcc -o time_gettimeofday time_gettimeofday.c && ./time_gettimeofday | egrep '\.(00|99) shows it is right... Thanks and best regards, Martin