aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-11-26 12:02:18 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2013-11-26 12:02:18 +0100
commit26ad256bd0badc17d70f347c27cf5ed0699eccc5 (patch)
tree4986260e9df19b5549ffb22ac7768fab8b9ddcfa
parent71f6c1aa433fb2be5c3e583ca350c1f9931817a5 (diff)
downloadbusybox-w32-26ad256bd0badc17d70f347c27cf5ed0699eccc5.tar.gz
busybox-w32-26ad256bd0badc17d70f347c27cf5ed0699eccc5.tar.bz2
busybox-w32-26ad256bd0badc17d70f347c27cf5ed0699eccc5.zip
logread: don't call shmdt() before exit, kernel does it for us.
function old new delta logread_main 472 466 -6 interrupted 20 9 -11 error_exit 20 - -20 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 0/2 up/down: 0/-37) Total: -37 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--sysklogd/logread.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/sysklogd/logread.c b/sysklogd/logread.c
index 53d771d28..92a562919 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)
@@ -185,7 +190,7 @@ int logread_main(int argc UNUSED_PARAM, char **argv)
185 fflush_all(); 190 fflush_all();
186 } while (follow); 191 } while (follow);
187 192
188 shmdt(shbuf); 193 /* shmdt(shbuf); - on Linux, shmdt is not mandatory on exit */
189 194
190 fflush_stdout_and_exit(EXIT_SUCCESS); 195 fflush_stdout_and_exit(EXIT_SUCCESS);
191} 196}