Skip to content

Commit

Permalink
[Interp] Make paths when searching source files relative to the root …
Browse files Browse the repository at this point in the history
…path of the process (closes #54 by Tomasz Kontusz @ktosiek).
  • Loading branch information
liske committed Jan 15, 2017
1 parent 57463d1 commit 4e020cb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ needrestart (2.11) unstable; urgency=medium
(Debian Bug#844283 by Paul Wise <pabs@debian.org>)
- [Core] Add display-manager 'lxdm' to override.
(Debian Bug#845996 by Rodrigo Campos <rodrigo@sdfg.com.ar>)
- [Interp] Make paths when searching source files relative to the root
path of the process.
(github issue #54 by Tomasz Kontusz @ktosiek)

-- Thomas Liske <thomas@fiasko-nw.net>

Expand Down
2 changes: 1 addition & 1 deletion perl/lib/NeedRestart/Interp/Java.pm
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ sub files {
my $pid = shift;

my %ret = map {
my $stat = nr_stat($_);
my $stat = nr_stat("/proc/$pid/root/$_");
$_ => ( defined($stat) ? $stat->{ctime} : undef );
} map {
my $l = readlink;
Expand Down
6 changes: 3 additions & 3 deletions perl/lib/NeedRestart/Interp/Perl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ sub source {
return ();
}
my $cwd = getcwd();
chdir($ptable->{cwd});
chdir("/proc/$pid/root/$ptable->{cwd}");

# get original ARGV
(my $bin, local @ARGV) = nr_parse_cmd($pid);
Expand Down Expand Up @@ -104,7 +104,7 @@ sub files {
return ();
}
my $cwd = getcwd();
chdir($ptable->{cwd});
chdir("/proc/$pid/root/$ptable->{cwd}");

# get original ARGV
(my $bin, local @ARGV) = nr_parse_cmd($pid);
Expand Down Expand Up @@ -167,7 +167,7 @@ sub files {
}

my %ret = map {
my $stat = nr_stat($href->{$_}->{file});
my $stat = nr_stat("/proc/$pid/root/$href->{$_}->{file}");
$href->{$_}->{file} => ( defined($stat) ? $stat->{ctime} : undef );
} keys %$href;

Expand Down
8 changes: 4 additions & 4 deletions perl/lib/NeedRestart/Interp/Python.pm
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ sub source {
return ();
}
my $cwd = getcwd();
chdir($ptable->{cwd});
chdir("/proc/$pid/root/$ptable->{cwd}");

# get original ARGV
(my $bin, local @ARGV) = nr_parse_cmd($pid);
Expand Down Expand Up @@ -135,7 +135,7 @@ sub files {
return ();
}
my $cwd = getcwd();
chdir($ptable->{cwd});
chdir("/proc/$pid/root/$ptable->{cwd}");

# get original ARGV
(my $bin, local @ARGV) = nr_parse_cmd($pid);
Expand Down Expand Up @@ -198,7 +198,7 @@ sub files {
chomp($path);
$path =~ s/^\['//;
$path =~ s/'\$//;
@path = split("', '", $path);
@path = map { "/proc/$pid/root/$_"; } split("', '", $path);
}
else {
print STDERR "$LOGPREF #$pid: failed to retrieve include path\n" if($self->{debug});
Expand All @@ -208,7 +208,7 @@ sub files {
_scan($self->{debug}, $pid, $src, \%files, \@path);

my %ret = map {
my $stat = nr_stat($_);
my $stat = nr_stat("/proc/$pid/root/$_");
$_ => ( defined($stat) ? $stat->{ctime} : undef );
} keys %files;

Expand Down
8 changes: 4 additions & 4 deletions perl/lib/NeedRestart/Interp/Ruby.pm
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ sub source {
return ();
}
my $cwd = getcwd();
chdir($ptable->{cwd});
chdir("/proc/$pid/root/$ptable->{cwd}");

# get original ARGV
(my $bin, local @ARGV) = nr_parse_cmd($pid);
Expand Down Expand Up @@ -132,7 +132,7 @@ sub files {
return ();
}
my $cwd = getcwd();
chdir($ptable->{cwd});
chdir("/proc/$pid/root/$ptable->{cwd}");

# get original ARGV
(my $bin, local @ARGV) = nr_parse_cmd($pid);
Expand Down Expand Up @@ -184,15 +184,15 @@ sub files {

# get include path
my $rbread = nr_fork_pipe($self->{debug}, $ptable->{exec}, '-e', 'puts $:');
my @path = <$rbread>;
my @path = map { "/proc/$pid/root/$_"; } <$rbread>;
close($rbread);
chomp(@path);

my %files;
_scan($self->{debug}, $pid, $src, \%files, \@path);

my %ret = map {
my $stat = nr_stat($_);
my $stat = nr_stat("/proc/$pid/root/$_");
$_ => ( defined($stat) ? $stat->{ctime} : undef );
} keys %files;

Expand Down

0 comments on commit 4e020cb

Please sign in to comment.