aboutsummaryrefslogtreecommitdiff
path: root/sysklogd
diff options
context:
space:
mode:
Diffstat (limited to 'sysklogd')
-rw-r--r--sysklogd/logread.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/sysklogd/logread.c b/sysklogd/logread.c
index 2b6415f47..bea73d932 100644
--- a/sysklogd/logread.c
+++ b/sysklogd/logread.c
@@ -49,6 +49,7 @@ struct globals {
49 memcpy(SMrup, init_sem, sizeof(init_sem)); \ 49 memcpy(SMrup, init_sem, sizeof(init_sem)); \
50} while (0) 50} while (0)
51 51
52#if 0
52static void error_exit(const char *str) NORETURN; 53static void error_exit(const char *str) NORETURN;
53static void error_exit(const char *str) 54static void error_exit(const char *str)
54{ 55{
@@ -56,6 +57,10 @@ static void error_exit(const char *str)
56 shmdt(shbuf); 57 shmdt(shbuf);
57 bb_perror_msg_and_die(str); 58 bb_perror_msg_and_die(str);
58} 59}
60#else
61/* On Linux, shmdt is not mandatory on exit */
62# define error_exit(str) bb_perror_msg_and_die(str)
63#endif
59 64
60/* 65/*
61 * sem_up - up()'s a semaphore. 66 * sem_up - up()'s a semaphore.
@@ -68,7 +73,7 @@ static void sem_up(int semid)
68 73
69static void interrupted(int sig) 74static void interrupted(int sig)
70{ 75{
71 shmdt(shbuf); 76 /* shmdt(shbuf); - on Linux, shmdt is not mandatory on exit */
72 kill_myself_with_sig(sig); 77 kill_myself_with_sig(sig);
73} 78}
74 79
@@ -84,12 +89,12 @@ int logread_main(int argc UNUSED_PARAM, char **argv)
84 89
85 log_shmid = shmget(KEY_ID, 0, 0); 90 log_shmid = shmget(KEY_ID, 0, 0);
86 if (log_shmid == -1) 91 if (log_shmid == -1)
87 bb_perror_msg_and_die("can't find syslogd buffer"); 92 bb_perror_msg_and_die("can't %s syslogd buffer", "find");
88 93
89 /* Attach shared memory to our char* */ 94 /* Attach shared memory to our char* */
90 shbuf = shmat(log_shmid, NULL, SHM_RDONLY); 95 shbuf = shmat(log_shmid, NULL, SHM_RDONLY);
91 if (shbuf == NULL) 96 if (shbuf == NULL)
92 bb_perror_msg_and_die("can't access syslogd buffer"); 97 bb_perror_msg_and_die("can't %s syslogd buffer", "access");
93 98
94 log_semid = semget(KEY_ID, 0, 0); 99 log_semid = semget(KEY_ID, 0, 0);
95 if (log_semid == -1) 100 if (log_semid == -1)
@@ -121,7 +126,7 @@ int logread_main(int argc UNUSED_PARAM, char **argv)
121 shbuf_data = shbuf->data; /* pointer! */ 126 shbuf_data = shbuf->data; /* pointer! */
122 127
123 if (DEBUG) 128 if (DEBUG)
124 printf("cur:%d tail:%i size:%i\n", 129 printf("cur:%u tail:%u size:%u\n",
125 cur, shbuf_tail, shbuf_size); 130 cur, shbuf_tail, shbuf_size);
126 131
127 if (!follow) { 132 if (!follow) {
@@ -182,9 +187,10 @@ int logread_main(int argc UNUSED_PARAM, char **argv)
182 } 187 }
183 free(copy); 188 free(copy);
184#endif 189#endif
190 fflush_all();
185 } while (follow); 191 } while (follow);
186 192
187 shmdt(shbuf); 193 /* shmdt(shbuf); - on Linux, shmdt is not mandatory on exit */
188 194
189 fflush_stdout_and_exit(EXIT_SUCCESS); 195 fflush_stdout_and_exit(EXIT_SUCCESS);
190} 196}