[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
glibc-2.2.3, glibc-2.3.2: `getlogin' resets `usec' part of the itimer in
From: |
Ivan Shmakov |
Subject: |
glibc-2.2.3, glibc-2.3.2: `getlogin' resets `usec' part of the itimer interval |
Date: |
Sat, 19 Jul 2003 01:50:41 +0700 |
Please look at the code (suggested by Thierry EXCOFFIER):
$ cat >getlogin-test.c <<\EOF
#include <sys/time.h>
void display_itimer ()
{
struct itimerval itv;
getitimer (ITIMER_REAL, &itv);
printf ("itv.it_interval.tv_usec = %d\n", itv.it_interval.tv_usec) ;
}
int main(int argc,char **argv)
{
struct itimerval itv;
itv.it_interval.tv_sec = 0;
itv.it_interval.tv_usec = 99999 ;
itv.it_value = itv.it_interval ;
setitimer (ITIMER_REAL, &itv, 0) ;
display_itimer() ;
getlogin() ;
display_itimer() ;
return 0 ;
}
EOF
$ gcc -o getlogin-test getlogin-test.c
$ ./getlogin-test
itv.it_interval.tv_usec = 100000
itv.it_interval.tv_usec = 0 <- there's expected to be the same value!
$
Ie. after call to `getlogin' `usec' part of timer interval is
reset to zero. Further investigating of the problem shows
that there's bug (feature?) in `LOCK_FILE' in
`glibc-2.3.2/sysdeps/generic/utmp_file.c'. Firstly, an old
timer value is saved using:
54 old_timeout = alarm (0); \
Then it is restored with:
85 if (old_timeout != 0) \
86 alarm (old_timeout); \
So that `usec' part of the timer is completely lost. The
``right way'' is to use `getitimer'/`setitimer' instead, but
what should be done with `it_value' part?
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- glibc-2.2.3, glibc-2.3.2: `getlogin' resets `usec' part of the itimer interval,
Ivan Shmakov <=