Changeset 379 for trunk/src/sh_tools.c


Ignore:
Timestamp:
Nov 28, 2011, 9:56:30 PM (13 years ago)
Author:
katerina
Message:

Fix for ticket #277 (sigpipe).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_tools.c

    r352 r379  
    10461046  int    num_sel;
    10471047 
    1048   struct  sigaction  new_act;
    1049   struct  sigaction  old_act;
    10501048  char    errbuf[SH_ERRBUF_SIZE];
    10511049
    10521050  SL_ENTER(_("sh_write_select"));
    10531051
    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  
    10611052  FD_ZERO(&fds);
    10621053  FD_SET(sockfd, &fds);
     
    10861077              continue;
    10871078            *w_error = errno;
    1088             sigaction (SIGPIPE, &old_act, NULL);
     1079
    10891080            sh_error_message(*w_error, errbuf, sizeof(errbuf));
    10901081            sh_error_handle (SH_ERR_INFO, FIL__, __LINE__, errno, MSG_E_SUBGEN,
     
    11071098              continue;
    11081099            *w_error = errno;
    1109             sigaction (SIGPIPE, &old_act, NULL);
     1100
    11101101            sh_error_message(*w_error, errbuf, sizeof(errbuf));
    11111102            sh_error_handle (SH_ERR_INFO, FIL__, __LINE__, errno, MSG_E_SUBGEN,
     
    11361127            *w_error = 0;
    11371128#endif
    1138             sigaction (SIGPIPE, &old_act, NULL);
     1129
    11391130            TPT(( 0, FIL__, __LINE__, _("msg=<Timeout>\n")));
    11401131            SL_RETURN( countbytes, _("sh_write_select"));
     
    11621153          {
    11631154            *w_error = errno;
    1164             sigaction (SIGPIPE, &old_act, NULL);
     1155
    11651156            sh_error_message(*w_error, errbuf, sizeof(errbuf));
    11661157            sh_error_handle (SH_ERR_INFO, FIL__, __LINE__, errno, MSG_E_SUBGEN,
     
    11741165          {
    11751166            *w_error = errno;
    1176             sigaction (SIGPIPE, &old_act, NULL);
     1167
    11771168            TPT(( 0, FIL__, __LINE__, _("msg=<count == 0>\n")));
    11781169            SL_RETURN( countbytes, _("sh_write_select"));
     
    11801171      }
    11811172  }
    1182 
    1183 
    1184   /* restore signal handler
    1185    */
    1186   sigaction (SIGPIPE, &old_act, NULL);
    11871173
    11881174  *w_error = 0;
Note: See TracChangeset for help on using the changeset viewer.