aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-07-22 20:57:28 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-07-22 20:57:28 +0000
commitf54e62a3f2a7e435605731dbb53f1bceafd31014 (patch)
tree8a53aa96203373e17ef7293ca1793536cc20e3d5
parent41660c5b2d78dbe58a6861699a348158c0aef3c3 (diff)
downloadbusybox-w32-f54e62a3f2a7e435605731dbb53f1bceafd31014.tar.gz
busybox-w32-f54e62a3f2a7e435605731dbb53f1bceafd31014.tar.bz2
busybox-w32-f54e62a3f2a7e435605731dbb53f1bceafd31014.zip
inetd: do not trash errno in signal handlers;
in CHLD handler, stop looping through services when pid is found function old new delta reread_config_file 1072 1092 +20 retry_network_setup 55 69 +14 reap_child 132 130 -2
-rw-r--r--networking/inetd.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/networking/inetd.c b/networking/inetd.c
index 19434aca4..9ebec19a5 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -894,9 +894,10 @@ static void reread_config_file(int sig UNUSED_PARAM)
894 sigset_t omask; 894 sigset_t omask;
895 unsigned n; 895 unsigned n;
896 uint16_t port; 896 uint16_t port;
897 int save_errno = errno;
897 898
898 if (!reopen_config_file()) 899 if (!reopen_config_file())
899 return; 900 goto ret;
900 for (sep = serv_list; sep; sep = sep->se_next) 901 for (sep = serv_list; sep; sep = sep->se_next)
901 sep->se_checked = 0; 902 sep->se_checked = 0;
902 903
@@ -1055,6 +1056,8 @@ static void reread_config_file(int sig UNUSED_PARAM)
1055 free(sep); 1056 free(sep);
1056 } 1057 }
1057 restore_sigmask(&omask); 1058 restore_sigmask(&omask);
1059 ret:
1060 errno = save_errno;
1058} 1061}
1059 1062
1060static void reap_child(int sig UNUSED_PARAM) 1063static void reap_child(int sig UNUSED_PARAM)
@@ -1068,24 +1071,27 @@ static void reap_child(int sig UNUSED_PARAM)
1068 pid = wait_any_nohang(&status); 1071 pid = wait_any_nohang(&status);
1069 if (pid <= 0) 1072 if (pid <= 0)
1070 break; 1073 break;
1071 for (sep = serv_list; sep; sep = sep->se_next) 1074 for (sep = serv_list; sep; sep = sep->se_next) {
1072 if (sep->se_wait == pid) { 1075 if (sep->se_wait != pid)
1073 /* One of our "wait" services */ 1076 continue;
1074 if (WIFEXITED(status) && WEXITSTATUS(status)) 1077 /* One of our "wait" services */
1075 bb_error_msg("%s: exit status 0x%x", 1078 if (WIFEXITED(status) && WEXITSTATUS(status))
1076 sep->se_program, WEXITSTATUS(status)); 1079 bb_error_msg("%s: exit status 0x%x",
1077 else if (WIFSIGNALED(status)) 1080 sep->se_program, WEXITSTATUS(status));
1078 bb_error_msg("%s: exit signal 0x%x", 1081 else if (WIFSIGNALED(status))
1079 sep->se_program, WTERMSIG(status)); 1082 bb_error_msg("%s: exit signal 0x%x",
1080 sep->se_wait = 1; 1083 sep->se_program, WTERMSIG(status));
1081 add_fd_to_set(sep->se_fd); 1084 sep->se_wait = 1;
1082 } 1085 add_fd_to_set(sep->se_fd);
1086 break;
1087 }
1083 } 1088 }
1084 errno = save_errno; 1089 errno = save_errno;
1085} 1090}
1086 1091
1087static void retry_network_setup(int sig UNUSED_PARAM) 1092static void retry_network_setup(int sig UNUSED_PARAM)
1088{ 1093{
1094 int save_errno = errno;
1089 servtab_t *sep; 1095 servtab_t *sep;
1090 1096
1091 alarm_armed = 0; 1097 alarm_armed = 0;
@@ -1098,6 +1104,7 @@ static void retry_network_setup(int sig UNUSED_PARAM)
1098#endif 1104#endif
1099 } 1105 }
1100 } 1106 }
1107 errno = save_errno;
1101} 1108}
1102 1109
1103static void clean_up_and_exit(int sig UNUSED_PARAM) 1110static void clean_up_and_exit(int sig UNUSED_PARAM)