kern/158641: Writing > 8192 bytes to a pipe blocks signal handling
Tom Hukins
tom at FreeBSD.org
Mon Jul 4 16:20:09 UTC 2011
>Number: 158641
>Category: kern
>Synopsis: Writing > 8192 bytes to a pipe blocks signal handling
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Jul 04 16:20:08 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator: Tom Hukins
>Release: FreeBSD 8.2-RELEASE-p2 i386
>Organization:
>Environment:
System: FreeBSD muscovy.scrubhole.org 8.2-RELEASE-p2 FreeBSD 8.2-RELEASE-p2 #0: Wed Jun 15 14:20:45 UTC 2011 root at muscovy.scrubhole.org:/home/obj/home/src/RELENG_8_2_2011-06-15/sys/GENERIC i386
>Description:
When a pipe has more than 8192 bytes written to it, the current process
hangs and does not handle signals correctly.
>How-To-Repeat:
#include <sys/types.h>
#include <sys/uio.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#define BUFFER_LENGTH 16384
void catch_alrm(int sig_num) {
printf("Alarm received\n");
fflush(stdout);
}
int main (int argc, char **argv) {
char buff_read[BUFFER_LENGTH];
int pdes[2];
if ( pipe(pdes) != 0) {
return 1;
}
signal(SIGALRM, catch_alrm);
int mypid = getpid();
write( pdes[1], argv[1], strlen(argv[1]) );
kill(mypid, SIGALRM);
return 0;
}
/*
Save the above as "pipefreeze.c", then run:
% cc -g -Wall pipefreeze.c && ./a.out HELLO
% perl -e 'print q(x) x 8192' | xargs ./a.out &
The first input of < 8192 bytes works fine, the second does not.
Sending "kill -ALRM PID" to the second process in the second example
terminates the process, but does not call the signal handler.
*/
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list