On Friday 15 October 2010 19:46, [email protected] wrote:
> Sure. Here's the command and then the results.
>
> # strace -o /tmp/log busybox seq 4 0 8 | head -n 5
> 4
> 4
> 4
> 4
> 4
> [ctrl-c required to exit back to shell]
> # cat /tmp/log
> execve("/bin/busybox", ["busybox", "seq", "4", "0", "8"], [/* 14 vars */]) = 0
> brk(0) = 0x73000
> uname({sys="Linux", node="palm-webos", ...}) = 0
> mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
> 0x35575000
....
> getuid32() = 0
> fstat64(1, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
> mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
> 0x35578000
> write(1, "4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n"..., 1024) = 1024
> write(1, "4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n"..., 1024) = -1
> EPIPE (Broken pipe)
> --- SIGPIPE (Broken pipe) @ 0 (0) ---
> write(1, "\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4"..., 1024) = -1
> EPIPE (Broken pipe)
> --- SIGPIPE (Broken pipe) @ 0 (0) ---
> write(1, "\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4\n4"..., 1024) = -1
> EPIPE (Broken pipe)
> --- SIGPIPE (Broken pipe) @ 0 (0) ---
> [ goes on forever ]
The parent process has SIGPIPE set to be ignored or masked. This is not
normally an expected case. I think you need to figure out why this happens
on your system ("trap '' SIGPIPE" somewhere in startup script?),
otherwise you'll see a lot of funny behavior from other programs too.
seq inherited this setting, therefore it doesn't die.
Meanwhile, please try the attached patch. It makes seq exit on write errors.
--
vda
diff -ad -urpN busybox.6/coreutils/seq.c busybox.7/coreutils/seq.c
--- busybox.6/coreutils/seq.c 2010-10-16 21:46:49.000000000 +0200
+++ busybox.7/coreutils/seq.c 2010-10-17 12:34:31.000000000 +0200
@@ -86,7 +86,8 @@ int seq_main(int argc, char **argv)
v = first;
n = 0;
while (increment >= 0 ? v <= last : v >= last) {
- printf("%s%0*.*f", sep, width, frac_part, v);
+ if (printf("%s%0*.*f", sep, width, frac_part, v) < 0)
+ break; /* I/O error, bail out (yes, this really happens) */
sep = opt_s;
/* v += increment; - would accumulate floating point errors */
n++;
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox