Bugs: Browse | Submit New | Admin

[#10627] Short read with readline, popen and timeout - first byte of the line disappears

Date:
2007-05-06 08:41
Priority:
3
Submitted By:
Pawel Pokrywka (cog)
Assigned To:
Akinori MUSHA (knu)
Category:
Files / Dirs / IO
State:
Open
Platform:
 
Summary:
Short read with readline, popen and timeout - first byte of the line disappears

Detailed description
Hello,

Popen()'ed subprocess writes "123\n" on stdout, while readline() or gets() sometimes returns "23\n".
Readline() is invoked from timeout() block.

Lower timeout is, bug probability increases.

I have attached proof of concept code which clearly demonstrate the bug. I tested the bug with the following
compilations:

- ruby 1.8.4 (2005-12-24) [i486-linux] (Ubuntu 6.10) - bug exists
- ruby 1.8.5 (2006-08-25) [i486-linux] (Ubuntu 6.10) - bug exists
- ruby 1.9.0 (2006-06-08) [i486-linux] (Ubuntu 7.04) - bug fixed

Add A Comment: Notepad

Please login


Followup

Message
Date: 2007-05-06 08:44
Sender: Pawel Pokrywka

print-lines script follows:
#!/bin/sh
while :
do
echo $@
sleep 0.03
done

Attached Files:

Name Description Download
test1 ruby code Download

Changes:

Field Old Value Date By
assigned_tonone2007-06-12 03:21zenspider
category_idNone2007-06-12 03:18zenspider
File Added1947: test12007-05-06 08:41cog