Strange echo behaviour
Peter Korsgaard
jacmet at sunsite.dk
Thu Jan 27 09:59:13 UTC 2011
>>>>> "Baruch" == Baruch Siach <baruch at tkos.co.il> writes:
>> The fix would be something like:
Baruch> I'm not sure. With this applied I get:
Baruch> write(1, "test\n", 5) = 0
Baruch> write(1, "test\n", 5) = 0
Baruch> write(1, "test\n", 5) = 0
Baruch> write(1, "test\n", 5) = 0
Baruch> write(1, "test\n", 5) = 0
Baruch> endlessly. Shouldn't write() return some kind of error, say -EINVAL?
Well, evdev can also consume 16 byte input_event structures, so if you
don't write a multiple of 16 bytes, it should consume all the complete
structures, and return the remainder.
In the error case where you don't write even a single complete struct,
it shouldn't consume anything, so return 0. But I agree that this will
never do anything sensible with echo, so perhaps it would make more
sense to return -EINVAL then.
Looking closer at evdev_read(), I see that they do return -EINVAL for
reads < sizeof(struct input_event), so I'll send an updated patch doing
that.
--
Bye, Peter Korsgaard
More information about the busybox
mailing list