Open kocoureasy opened 3 years ago
This fix looks very Docker specific. Ideally we would deal with this in a way that detects all containerization, not just docker.
Nice code which detect all of this is in detect_container() or detect_container_files() function from systemd here https://github.com/systemd/systemd/blob/main/src/basic/virt.c
I would propose to check the process tree to see if the current process' ultimate ancestor is process=1.
sub is_in_container {
return unless -e "/proc/$$/stat";
my $pid = $$;
while ($pid > 1) {
open my $fh, '<', "/proc/$pid/stat";
($pid) = <$fh> =~ /\S+ \S+ \S+ (\S+)/;
}
return $pid != 1;
}
Hi, its similar of issue RT #130143, where test t/op/getppid.t fail in docker container. Problem is in function is_linux_container() which should properly return if perl is called in container, but not properly check new docker environment.
File proc_1.txt contain /proc/1/cgroup under Docker 20.10.3. File diff_getppid.txt contain fix for latest perl
Regards Igor
proc_1.txt diff_getppid.txt