summaryrefslogtreecommitdiff
path: root/blktrace.c
diff options
context:
space:
mode:
authorAlex Polvi <alex@polvi.net>2006-05-08 07:15:50 +0200
committerJens Axboe <axboe@suse.de>2006-05-08 07:15:50 +0200
commit38e1f0c68bb7a808d889e639530c69830d110f75 (patch)
tree8fe94b548b2d8650c58e722e8a92b695b218b7cb /blktrace.c
parent1452478f2d1b27916c7cba6e3976ed2129533c73 (diff)
downloadblktrace-38e1f0c68bb7a808d889e639530c69830d110f75.tar.gz
blktrace-38e1f0c68bb7a808d889e639530c69830d110f75.tar.bz2
[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.
Diffstat (limited to 'blktrace.c')
-rw-r--r--blktrace.c1
1 files changed, 1 insertions, 0 deletions
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;