Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16133
| From | Martin Schulte <gnu@schrader-schulte.de> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: Difference between EPOCHREALTIME and EPOCHSECONDS |
| Date | 2020-04-14 19:43 +0200 |
| Message-ID | <mailman.263.1586886227.3066.bug-bash@gnu.org> (permalink) |
| References | <E1jOH8S-0001Pc-VE@medium.hauri> <4ffdb354-3a55-e588-0d53-b170b6c0ca4f@case.edu> <20200414194334.b18fba820739b99e92c863be@schrader-schulte.de> |
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 <time.h>
#include <sys/time.h>
#include <stdio.h>
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
Back to gnu.bash.bug | Previous | Next | Find similar
Re: Difference between EPOCHREALTIME and EPOCHSECONDS Martin Schulte <gnu@schrader-schulte.de> - 2020-04-14 19:43 +0200
csiph-web