1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
Use libc's built-in getutXXX() functions for manipulating the file.
--- tcsh-6.13.00/tc.who.c.utmp 2004-08-17 17:19:44.541315488 +0200
+++ tcsh-6.13.00/tc.who.c 2004-08-17 17:22:12.251860072 +0200
@@ -165,12 +165,13 @@
watch_login(force)
int force;
{
- int utmpfd, comp = -1, alldone;
+ int comp = -1, alldone;
int firsttime = stlast == 1;
#ifdef BSDSIGS
sigmask_t omask;
#endif /* BSDSIGS */
struct utmp utmp;
+ struct utmp *uptr;
struct who *wp, *wpnew;
struct varent *v;
Char **vp = NULL;
@@ -263,18 +264,8 @@
return;
}
stlast = sta.st_mtime;
- if ((utmpfd = open(_PATH_UTMP, O_RDONLY|O_LARGEFILE)) < 0) {
- if (!force)
- xprintf(CGETS(26, 2,
- "%s cannot be opened. Please \"unset watch\".\n"),
- _PATH_UTMP);
-# ifdef BSDSIGS
- (void) sigsetmask(omask);
-# else
- (void) sigrelse(SIGINT);
-# endif
- return;
- }
+ utmpname(_PATH_UTMP);
+ setutent();
/*
* xterm clears the entire utmp entry - mark everyone on the status list
@@ -289,7 +280,8 @@
* Read in the utmp file, sort the entries, and update existing entries or
* add new entries to the status list.
*/
- while (read(utmpfd, (char *) &utmp, sizeof utmp) == sizeof utmp) {
+ while ((uptr = getutent())) {
+ memcpy(&utmp, uptr, sizeof(utmp));
# ifdef DEAD_PROCESS
# ifndef IRIS4D
@@ -385,7 +377,7 @@
wp->who_prev = wpnew; /* linked in now */
}
}
- (void) close(utmpfd);
+ endutent();
# if defined(UTHOST) && defined(_SEQUENT_)
endutent();
# endif
|