From: Alex Polvi Date: Mon, 8 May 2006 05:15:50 +0000 (+0200) Subject: [PATCH] blktrace.c should ignore SIGPIPE X-Git-Tag: blktrace-0.99.2~40 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=38e1f0c68bb7a808d889e639530c69830d110f75;p=blktrace.git [PATCH] blktrace.c should ignore SIGPIPE After sending a SIGINT to a "blktrace .. | blkparse .. " pipeline, occasionally I would not be able to run blktrace again. On my next run of the same pipeline I would get the following error: cs411vm:/usr/src/bt# ./blktrace -d /dev/sdb -o - | ./blkparse -i - BLKTRACESETUP: No such file or directory Failed to start trace on /dev/sdb After rebooting, I could reproduce this by starting the pipeline, and kicking off a big write and sending a SIGINT to blktrace. The following is what I used for a write: while [ 1 ] do dd if=/dev/zero of=/test/write bs=1M done It seemed like blktrace was not handling signals correctly, so I strace'd the process to see what was happening. Sure enough: --- SIGINT (Interrupt) @ 0 (0) --- ioctl(3, 0x1275, 0xb7fa6000) = 0 sigreturn() = ? (mask now []) write(1, "O\0\0\0\20\0\200\0\0\0\0\0\0\0\0\0\7taeN3\1\0\257R\260"..., 4096) = -1 EPIPE (Broken pipe) --- SIGPIPE (Broken pipe) @ 0 (0) --- +++ killed by SIGPIPE +++ Any idea what clean-up is not happening? I tried to figure it out, but my only work-around was a reboot. My patch against 2.6.17-rc3 just tells blktrace to ignore SIGPIPE. Nothing crazy. :) blktrace already does enough error checking elsewhere to handle a bad write. On a completely unrelated note, the write_data function calls fwrite, which will not return -1 on error. Instead you'll need to use ferror to check if there was a problem. I'm not sure if this is a cause of any bugs, but it seemed worth mentioning. Furthermore, I updated the URLs in the documentation to point at a valid git repo. --- diff --git a/blktrace.c b/blktrace.c index e345888..1be7233 100644 --- a/blktrace.c +++ b/blktrace.c @@ -1919,6 +1919,7 @@ int main(int argc, char *argv[]) signal(SIGHUP, handle_sigint); signal(SIGTERM, handle_sigint); signal(SIGALRM, handle_sigint); + signal(SIGPIPE, SIG_IGN); if (net_mode == Net_client && net_setup_client()) return 1; diff --git a/doc/blktrace.tex b/doc/blktrace.tex index 4c1c844..a81e2ee 100644 --- a/doc/blktrace.tex +++ b/doc/blktrace.tex @@ -51,7 +51,7 @@ three major components that are provided: The blktrace and blkparse utilities and associated kernel patch are provided as part of the following git repository: -rsync://rsync.kernel.org/pub/scm/linux/kernel/git/axboe/blktrace.git +git://git.kernel.org/pub/scm/linux/kernel/git/axboe/blktrace.git bt %-------------------------- \newpage\section{\label{sec:quick-start}Quick Start Guide} @@ -65,7 +65,7 @@ to your environment. As noted above, the kernel patch along with the blktrace and blkparse utilities are stored in a git repository. One simple way to get going would be: \begin{verbatim} -% git clone rsync://rsync.kernel.org/pub/scm/linux/kernel/git/axboe/blktrace.git bt +% git clone git://git.kernel.org/pub/scm/linux/kernel/git/axboe/blktrace.git bt % cd bt % git checkout \end{verbatim}