blob: 94d5291a37b10faad83686ea4988a45b20e64db3 (
plain) (
blame)
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
|
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/stat.h>
#include "config.h"
#include "pttstruct.h"
int main() {
#if 0
int i, shm, counter;
struct utmpfile_t *utmpshm;
shm = shmget(UTMPSHM_KEY, USHM_SIZE, SHM_R | SHM_W);
if(shm == -1) {
perror("shmget");
exit(0);
}
utmpshm = shmat(shm, NULL, 0);
if(utmpshm == (struct utmpfile_t *)-1) {
perror("shmat");
exit(0);
}
for(i = counter = 0; i < USHM_SIZE; i++)
if(SHM->uinfo[i].pid) {
char buf[256];
userinfo_t *f;
struct stat sb;
f = &utmpshm->uinfo[i];
sprintf(buf, "/proc/%d", f->pid);
if(stat(buf, &sb)) {
f->pid = 0;
utmpshm->number--;
counter++;
}
}
printf("clear %d slots\n", counter);
#endif
return 0;
}
|