Project

General

Profile

Bug #3034

Tail -n 1 don't work on /proc/curproc/map

Added by cpk over 1 year ago. Updated 9 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
VFS subsystem
Target version:
-
Start date:
05/09/2017
Due date:
% Done:

0%

Estimated time:

Description

If i run tail -n 1 /proc/curproc/map it will print 10 last lines.(wc says it is 11 but something is wrong here)
But then if i redirect output to file and then tail it it will print correct number of lines.

tail -n 1 /proc/curproc/map |wc -l
11 143 1111
tail -n 1 /proc/curproc/map > /tmp/tail-bug && tail -n 1 /tmp/tail-bug |wc
1 13 95

uname -a
DragonFly dfly-0 4.6-RELEASE DragonFly v4.6.0rc2-RELEASE #2: Sun Jul 24 14:47:27 EDT 2016 :/usr/obj/home/justin/release/4_6/sys/X86_64_GENERIC x86_64

History

#1 Updated by daftaupe 9 months ago

After looking at this issue, it seems that it's because /proc/curproc/map has a size of 0.
In the forward.c code, in that case we're at line 150, calling function rlines : rlines(fp, off, sbp);
But this function starts with a test :
if (!(size = sbp->st_size))
return;
and as the size of the file is 0 it returns immediately and display the whole file instead of the number of lines specified on the cli.

The call of display_lines(fp, off) instead of rlines(fp, off, sbp) seems to fix this issue.

Also available in: Atom PDF