Changeset 379
- Timestamp:
- Nov 28, 2011, 9:56:30 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/sh_unix.h
r373 r379 169 169 int sh_unix_run_command (const char * str); 170 170 171 /* Ignore SIGPIPE 172 */ 173 void sh_unix_ign_sigpipe(); 174 171 175 /* mlock utilities 172 176 */ -
trunk/src/samhain.c
r373 r379 1376 1376 /* -------- INIT -------- 1377 1377 */ 1378 sh_unix_ign_sigpipe(); 1378 1379 1379 1380 /* Restrict error logging to stderr. -
trunk/src/sh_err_console.c
r362 r379 290 290 /* static int logkey_seen = 0; */ 291 291 int error; 292 struct sigaction sa_new, sa_old;293 292 static int blockMe = 0; 294 293 int val_return; … … 311 310 #endif 312 311 313 sa_new.sa_handler = SIG_IGN;314 (void) sigemptyset(&sa_new.sa_mask);315 sa_new.sa_flags = 0;316 317 /* Ignore SIGPIPE in case the console is actually a pipe.318 */319 (void) retry_sigaction(FIL__, __LINE__, SIGPIPE, &sa_new, &sa_old);320 321 312 if (sh.flag.isdaemon == S_FALSE || OnlyStderr == S_TRUE) 322 313 { … … 331 322 * fprintf (stderr, "%s\n", errmsg); 332 323 */ 333 (void) retry_sigaction(FIL__, __LINE__, SIGPIPE, &sa_old, NULL);334 324 blockMe = 0; 335 325 SL_RETURN(0, _("sh_log_console")); … … 392 382 retval = 0; 393 383 394 (void) retry_sigaction(FIL__, __LINE__, SIGPIPE, &sa_old, NULL);395 384 blockMe = 0; 396 385 SL_RETURN(retval, _("sh_log_console")); -
trunk/src/sh_forward.c
r363 r379 5055 5055 unsigned long tchkold; 5056 5056 5057 struct sigaction new_act;5058 struct sigaction old_act;5059 5060 5057 int setsize_fd; 5061 5058 … … 5067 5064 5068 5065 SL_ENTER(_("sh_receive")); 5069 5070 /* ignore SIGPIPE (instead get EPIPE if connection is closed)5071 * --- we have called sh_unix_init() already ---5072 */5073 new_act.sa_handler = SIG_IGN;5074 sigemptyset( &new_act.sa_mask ); /* set an empty mask */5075 new_act.sa_flags = 0; /* init sa_flags */5076 retry_sigaction (FIL__, __LINE__, SIGPIPE, &new_act, &old_act);5077 5066 5078 5067 if ( sh_forward_printerr_final(0) < 0) -
trunk/src/sh_log_check.c
r362 r379 876 876 struct task_entry * entry; 877 877 878 struct sigaction new_act;879 struct sigaction old_act;880 881 878 volatile int status; 882 879 char * tmp; … … 886 883 if (logfile->fp) 887 884 { 888 /* ignore SIGPIPE (instead get EPIPE if connection is closed)889 */890 memset(&new_act, 0, sizeof(struct sigaction));891 new_act.sa_handler = SIG_IGN;892 (void) retry_sigaction (FIL__, __LINE__, SIGPIPE, &new_act, &old_act);893 894 885 /* Result cannot be larger than 8192, thus cast is ok 895 886 */ 896 887 status = (int) sh_string_read(s, logfile->fp, 8192); 897 898 /* restore old signal handler899 */900 (void) retry_sigaction (FIL__, __LINE__, SIGPIPE, &old_act, NULL);901 888 902 889 if (status <= 0) -
trunk/src/sh_mail.c
r362 r379 531 531 static int failcount = 0; 532 532 FILE * connfile = NULL; 533 534 struct sigaction old_act;535 struct sigaction new_act;536 533 537 534 static time_t fail_time = 0; … … 671 668 672 669 /* ---------- Connect ---------------------------------------- */ 673 674 /* -- Catch (ignore) 'broken pipe'.675 */676 new_act.sa_handler = SIG_IGN;677 sigemptyset( &new_act.sa_mask ); /* set an empty mask */678 new_act.sa_flags = 0; /* init sa_flags */679 680 (void) sigaction (SIGPIPE, &new_act, &old_act);681 670 682 671 errcount = 0; … … 825 814 } 826 815 827 /* --- Reset signal. ---828 */829 (void) sigaction (SIGPIPE, &old_act, NULL);830 831 816 if (errcount == address_num) 832 817 { -
trunk/src/sh_prelink.c
r374 r379 164 164 int status = 0; 165 165 char * p; 166 struct sigaction new_act;167 struct sigaction old_act;168 166 169 167 SL_ENTER(_("sh_prelink_run")); … … 256 254 SL_RETURN ((-1), _("sh_prelink_run")); 257 255 } 258 259 /* ignore SIGPIPE (instead get EPIPE if connection is closed)260 */261 new_act.sa_handler = SIG_IGN;262 (void) retry_sigaction (FIL__, __LINE__, SIGPIPE, &new_act, &old_act);263 256 264 257 /* read from pipe … … 275 268 } 276 269 277 /* restore old signal handler278 */279 (void) retry_sigaction (FIL__, __LINE__, SIGPIPE, &old_act, NULL);280 281 270 /* close pipe and return exit status 282 271 */ -
trunk/src/sh_processcheck.c
r374 r379 1022 1022 int status = 0; 1023 1023 char * p; 1024 struct sigaction new_act;1025 struct sigaction old_act;1026 1024 int retval = 0; 1027 1025 char dir[SH_PATHBUF]; … … 1076 1074 } 1077 1075 1078 /* ignore SIGPIPE (instead get EPIPE if connection is closed)1079 */1080 new_act.sa_handler = SIG_IGN;1081 (void) retry_sigaction (FIL__, __LINE__, SIGPIPE, &new_act, &old_act);1082 1083 1076 /* read from the open pipe 1084 1077 */ … … 1087 1080 retval = sh_processes_readps (task.pipe, res, str, len, flag, pid); 1088 1081 } 1089 1090 /* restore old signal handler1091 */1092 (void) retry_sigaction (FIL__, __LINE__, SIGPIPE, &old_act, NULL);1093 1082 1094 1083 /* close pipe and return exit status -
trunk/src/sh_tools.c
r352 r379 1046 1046 int num_sel; 1047 1047 1048 struct sigaction new_act;1049 struct sigaction old_act;1050 1048 char errbuf[SH_ERRBUF_SIZE]; 1051 1049 1052 1050 SL_ENTER(_("sh_write_select")); 1053 1051 1054 /* ignore SIGPIPE (instead get EPIPE if connection is closed)1055 */1056 new_act.sa_handler = SIG_IGN;1057 sigemptyset( &new_act.sa_mask ); /* set an empty mask */1058 new_act.sa_flags = 0; /* init sa_flags */1059 sigaction (SIGPIPE, &new_act, &old_act);1060 1061 1052 FD_ZERO(&fds); 1062 1053 FD_SET(sockfd, &fds); … … 1086 1077 continue; 1087 1078 *w_error = errno; 1088 sigaction (SIGPIPE, &old_act, NULL); 1079 1089 1080 sh_error_message(*w_error, errbuf, sizeof(errbuf)); 1090 1081 sh_error_handle (SH_ERR_INFO, FIL__, __LINE__, errno, MSG_E_SUBGEN, … … 1107 1098 continue; 1108 1099 *w_error = errno; 1109 sigaction (SIGPIPE, &old_act, NULL); 1100 1110 1101 sh_error_message(*w_error, errbuf, sizeof(errbuf)); 1111 1102 sh_error_handle (SH_ERR_INFO, FIL__, __LINE__, errno, MSG_E_SUBGEN, … … 1136 1127 *w_error = 0; 1137 1128 #endif 1138 sigaction (SIGPIPE, &old_act, NULL); 1129 1139 1130 TPT(( 0, FIL__, __LINE__, _("msg=<Timeout>\n"))); 1140 1131 SL_RETURN( countbytes, _("sh_write_select")); … … 1162 1153 { 1163 1154 *w_error = errno; 1164 sigaction (SIGPIPE, &old_act, NULL); 1155 1165 1156 sh_error_message(*w_error, errbuf, sizeof(errbuf)); 1166 1157 sh_error_handle (SH_ERR_INFO, FIL__, __LINE__, errno, MSG_E_SUBGEN, … … 1174 1165 { 1175 1166 *w_error = errno; 1176 sigaction (SIGPIPE, &old_act, NULL); 1167 1177 1168 TPT(( 0, FIL__, __LINE__, _("msg=<count == 0>\n"))); 1178 1169 SL_RETURN( countbytes, _("sh_write_select")); … … 1180 1171 } 1181 1172 } 1182 1183 1184 /* restore signal handler1185 */1186 sigaction (SIGPIPE, &old_act, NULL);1187 1173 1188 1174 *w_error = 0; -
trunk/src/sh_unix.c
r373 r379 699 699 } 700 700 701 void sh_unix_ign_sigpipe() 702 { 703 struct sigaction ignact; 704 705 ignact.sa_handler = SIG_IGN; /* signal action */ 706 sigemptyset( &ignact.sa_mask ); /* set an empty mask */ 707 ignact.sa_flags = 0; /* init sa_flags */ 708 709 #ifdef SIGPIPE 710 retry_sigaction(FIL__, __LINE__, SIGPIPE, &ignact, NULL); 711 #endif 712 713 return; 714 } 701 715 static 702 716 void sh_unix_siginstall (int goDaemon) … … 831 845 #endif 832 846 #ifdef SIGPIPE 833 #ifdef HAVE_PTHREAD834 847 retry_sigaction(FIL__, __LINE__, SIGPIPE, &ignact, &oldact); 835 #else836 retry_sigaction(FIL__, __LINE__, SIGPIPE, &act, &oldact);837 #endif838 848 #endif 839 849 #ifdef SIGALRM
Note:
See TracChangeset
for help on using the changeset viewer.