|
25 | 25 |
|
26 | 26 | #define _FILE_OFFSET_BITS 64 |
27 | 27 |
|
| 28 | +#define _GNU_SOURCE |
28 | 29 | #include <sys/types.h> |
29 | 30 | #include <stdio.h> |
30 | 31 | #include <fcntl.h> |
|
34 | 35 | #include <unistd.h> |
35 | 36 | #include <sys/time.h> |
36 | 37 | #include <sys/stat.h> |
| 38 | +#include <sys/wait.h> |
37 | 39 | #include <sys/ipc.h> |
38 | 40 | #include <sys/sem.h> |
39 | | -#include <sys/wait.h> |
40 | 41 |
|
41 | 42 | #include "atop.h" |
42 | 43 | #include "photoproc.h" |
@@ -101,7 +102,8 @@ struct sembuf semclaim = {0, -1, SEM_UNDO}, |
101 | 102 | semdecre = {1, -1, SEM_UNDO}, |
102 | 103 | semincre = {1, +1, SEM_UNDO}; |
103 | 104 |
|
104 | | -struct sembuf semreglock[] = {{0, -1, SEM_UNDO}, {1, -1, SEM_UNDO}}, |
| 105 | +struct sembuf semreglock[] = {{0, -1, SEM_UNDO|IPC_NOWAIT}, |
| 106 | + {1, -1, SEM_UNDO|IPC_NOWAIT}}, |
105 | 107 | semunlock = {1, +1, SEM_UNDO}; |
106 | 108 |
|
107 | 109 | /* |
@@ -174,11 +176,17 @@ acctswon(void) |
174 | 176 | FILE *cfp; |
175 | 177 | char shadowpath[128]; |
176 | 178 | struct flock flock; |
| 179 | + struct timespec maxsemwait = {3, 0}; |
177 | 180 |
|
178 | 181 | if (! droprootprivs() ) |
179 | 182 | mcleanstop(42, "failed to drop root privs\n"); |
180 | 183 |
|
181 | | - (void) semop(sempacctpubid, semreglock, 2); |
| 184 | + if (semtimedop(sempacctpubid, semreglock, 2, &maxsemwait) == -1) |
| 185 | + { |
| 186 | + acctfd = -1; |
| 187 | + regainrootprivs(); |
| 188 | + return 3; |
| 189 | + } |
182 | 190 |
|
183 | 191 | snprintf(shadowpath, sizeof shadowpath, "%s/%s/%s", |
184 | 192 | pacctdir, PACCTSHADOWD, PACCTSHADOWC); |
|
0 commit comments