Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Jul 2011 15:40:10 GMT
From:      Tom Hukins <tom@FreeBSD.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   kern/158641: Writing > 8192 bytes to a pipe blocks signal handling
Message-ID:  <201107041540.p64FeAYs073197@muscovy.scrubhole.org>
Resent-Message-ID: <201107041620.p64GK9Ew028303@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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@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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107041540.p64FeAYs073197>