Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/sysklogd/logread.c
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/sysklogd/logread.c
r1765 r2725 7 7 * Maintainer: Gennady Feldman <gfeldman@gena01.com> as of Mar 12, 2001 8 8 * 9 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.9 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 10 10 */ 11 11 … … 17 17 #define DEBUG 0 18 18 19 /* our shared key (syslogd.c and logread.c must be in sync) */ 19 20 enum { KEY_ID = 0x414e4547 }; /* "GENA" */ 20 21 21 st atic struct shbuf_ds {22 struct shbuf_ds { 22 23 int32_t size; // size of data - 1 23 24 int32_t tail; // end of message list 24 25 char data[1]; // messages 25 } *shbuf;26 }; 26 27 27 // Semaphore operation structures 28 static struct sembuf SMrup[1] = {{0, -1, IPC_NOWAIT | SEM_UNDO}}; // set SMrup 29 static struct sembuf SMrdn[2] = {{1, 0}, {0, +1, SEM_UNDO}}; // set SMrdn 28 static const struct sembuf init_sem[3] = { 29 {0, -1, IPC_NOWAIT | SEM_UNDO}, 30 {1, 0}, {0, +1, SEM_UNDO} 31 }; 30 32 33 struct globals { 34 struct sembuf SMrup[1]; // {0, -1, IPC_NOWAIT | SEM_UNDO}, 35 struct sembuf SMrdn[2]; // {1, 0}, {0, +1, SEM_UNDO} 36 struct shbuf_ds *shbuf; 37 } FIX_ALIASING; 38 #define G (*(struct globals*)&bb_common_bufsiz1) 39 #define SMrup (G.SMrup) 40 #define SMrdn (G.SMrdn) 41 #define shbuf (G.shbuf) 42 #define INIT_G() do { \ 43 memcpy(SMrup, init_sem, sizeof(init_sem)); \ 44 } while (0) 31 45 32 static void error_exit(const char *str) ATTRIBUTE_NORETURN;46 static void error_exit(const char *str) NORETURN; 33 47 static void error_exit(const char *str) 34 48 { … … 47 61 } 48 62 49 static void interrupted(int sig ATTRIBUTE_UNUSED)63 static void interrupted(int sig UNUSED_PARAM) 50 64 { 51 65 signal(SIGINT, SIG_IGN); 52 66 shmdt(shbuf); 53 exit( 0);67 exit(EXIT_SUCCESS); 54 68 } 55 69 56 int logread_main(int argc, char **argv) ;57 int logread_main(int argc , char **argv)70 int logread_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 71 int logread_main(int argc UNUSED_PARAM, char **argv) 58 72 { 59 intcur;73 unsigned cur; 60 74 int log_semid; /* ipc semaphore id */ 61 75 int log_shmid; /* ipc shared memory id */ 62 76 smallint follow = getopt32(argv, "f"); 77 78 INIT_G(); 63 79 64 80 log_shmid = shmget(KEY_ID, 0, 0); … … 120 136 if (cur == shbuf_tail) { 121 137 sem_up(log_semid); 122 fflush (stdout);138 fflush_all(); 123 139 sleep(1); /* TODO: replace me with a sleep_on */ 124 140 continue;
Note:
See TracChangeset
for help on using the changeset viewer.