-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
I used to use this command to generate random passwords:
tr -cd '[:alnum:]' < /dev/urandom | fold -w16 | head -n1
To my surprise, after upgrading to Ubuntu 25.10, it doesn't work, it just hangs.
The head command doesn't matter:
tr -cd '[:alnum:]' < /dev/urandom | fold -w16
strace shows fold only reads, never writes to output:
read(0, "dEyUbAHqRD9F6yH12quGo57WL86euXpc"..., 8192) = 8192
read(0, "1a5llTn2GvsmmMehGn99gznpz96HA14X"..., 8192) = 8192
read(0, "JmI1XFLD9fh1eoUp2qyXsxs5l52RL9vg"..., 8192) = 8192
read(0, "HCUhmOKwGROCxQkwy67Bx4KtkIXdOhnV"..., 8192) = 8192
read(0, "DImfGs6B3YTZZOr6pBHZ5v2BYaGuyypO"..., 8192) = 8192
read(0, "roYZ2f5DvrFZ3Z8c6lDnvGHzg06jAT7M"..., 8192) = 8192
read(0, "Yx89u7MkDwZVfj9eCxdeMOCYkZHo0lDz"..., 8192) = 8192
read(0, "vhtomhgBZEjSO6o1NhuJpavUdXOqYzb8"..., 8192) = 8192
read(0, "ryauy25EliZ85tjcjL6CwSNuRKYNxYTH"..., 8192) = 8192
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7d28590f8000
For some reason, if I pipe a regular file instead of /dev/urandom, it works:
$ tr -cd '[:alnum:]' < "$(which fold)" | fold -w16 | head
ELFJ8HH44PP66ppp
00000DxStdPtdttt
DDQtdRtdGNUGNU92
slib64ldlinuxx86
64so28em09uCdNU1
Building from current source (commit 0b0ba60) reproduces the issue:
cargo build --release
ln -vs target/release/coreutils ./fold
ln -vs target/release/coreutils ./tr
./tr -cd '[:alnum:]' < /dev/urandom | ./fold -w16
I gave this title, "fold doesn't flush output when input is a pipe", as my best knowledge, but I may miss the point. The tr command is also involved and might also be the culprit, but since strace shows it constantly writes output, also without fold it litters my terminal in a moment like no tomorrow, I'm not suspicious. The title might be changed if we know more about the problem and in that light it doesn't seem appropriate. The problem might have been already reported with a more accurate description, but I couldn't find it (though there are various other issues regarding pipes those might be related somehow). Wish I knew more.