Bug 8129 - libc_r write() on broken pipe, no error return.
Summary: libc_r write() on broken pipe, no error return.
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 2.2.7-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 1998-10-02 15:00 UTC by dockes
Modified: 1998-12-11 20:21 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dockes 1998-10-02 15:00:00 UTC
When linking with libc_r and catching SIGPIPE, a write() call on a
pipe or socket with no reader doesn't return an error. The program
seems to be looping sending/catching SIGPIPES.

This is a real problem for a network server that talks to the client
before forking, or needs to cleanup when the client goes away.

Fix: 

No idea.
How-To-Repeat: 
The following trivial program can be used. Pipe it to 'more' and type 'q'.
If the program was linked normally, it prints the normal error 
(write: Broken pipe). 
If linked with libc_r it loops forever, printing "Got sig 13".

#include <stdio.h>
#include <signal.h>
void sigshow(int sig)
{
  fprintf(stderr, "Got sig %d\n", sig);
}
main()
{
  struct sigaction sa;
  sa.sa_flags = 0;
  sigemptyset(&sa.sa_mask);
  sa.sa_handler = sigshow;
  sigaction(SIGPIPE, &sa, NULL);
  for (;;) {
    if (write(1, "THIS IS DATA\n", 13) != 13) {
      perror("write");
      exit(1);
    }
  }
}
Comment 1 Steve Price freebsd_committer freebsd_triage 1998-12-11 20:21:19 UTC
State Changed
From-To: open->closed

Confirmed fixed by originator.