I noticed something interesting while writing a tool that reads /proc/*/smaps_rollup. The following code won't print any errors or warnings, as long as Unicode::UTF8 is not installed:
martin ~ # cat test.pl
#!/usr/bin/perl -CSDAL
use warnings;
use strict;
use Path::Tiny;
use DDP;
my @lines = Path::Tiny::path("/proc/2/smaps_rollup")->lines_utf8({chomp => 1});
p @lines;
martin ~ # ./test.pl
[]
But after installing Unicode::UTF8, it'll print a warning:
martin ~ # apt install libunicode-utf8-perl
Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.
Statusinformationen werden eingelesen.... Fertig
Die folgenden NEUEN Pakete werden installiert:
libunicode-utf8-perl
0 aktualisiert, 1 neu installiert, 0 zu entfernen und 0 nicht aktualisiert.
Es müssen 20,0 kB an Archiven heruntergeladen werden.
Nach dieser Operation werden 56,3 kB Plattenplatz zusätzlich benutzt.
Holen:1 http://deb.debian.org/debian buster/main amd64 libunicode-utf8-perl amd64 0.62-1 [20,0 kB]
Es wurden 20,0 kB in 0 s geholt (412 kB/s).
Vormals nicht ausgewähltes Paket libunicode-utf8-perl wird gewählt.
(Lese Datenbank ... 225569 Dateien und Verzeichnisse sind derzeit installiert.)
Vorbereitung zum Entpacken von .../libunicode-utf8-perl_0.62-1_amd64.deb ...
Entpacken von libunicode-utf8-perl (0.62-1) ...
libunicode-utf8-perl (0.62-1) wird eingerichtet ...
Trigger für man-db (2.8.5-2) werden verarbeitet ...
martin ~ # ./test.pl
Use of uninitialized value in subroutine entry at /usr/share/perl5/Path/Tiny.pm line 1809.
[]
The reason for the error is that reading from some /proc/*/smaps_rollup files will throw ESRCH:
martin ~ # LANG=C perf trace --failure cat /proc/2/smaps_rollup > /dev/null
cat: /proc/2/smaps_rollup: No such process
0.179 ( 0.013 ms): cat/3165 access(filename: 0x9c8c6300, mode: R ) = -1 ENOENT No such file or directory
1.431 ( 0.007 ms): cat/3165 read(fd: 3, buf: 0x7f3f9c376000, count: 131072 ) = -1 ESRCH No such process
I noticed something interesting while writing a tool that reads
/proc/*/smaps_rollup
. The following code won't print any errors or warnings, as long asUnicode::UTF8
is not installed:But after installing
Unicode::UTF8
, it'll print a warning:The reason for the error is that reading from some
/proc/*/smaps_rollup
files will throw ESRCH: