summaryrefslogtreecommitdiffstats
path: root/perl-install/common.pm
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mandriva.org>2008-08-07 07:29:03 +0000
committerThierry Vignaud <tv@mandriva.org>2008-08-07 07:29:03 +0000
commitec7b4cc292c32a50422f4af83041c6cc0e6f0613 (patch)
tree9de1073cd3b9ac1314638c9c09a41b244d901ca9 /perl-install/common.pm
parent46e4a32ead925c6195f9482a59552e76c0fc238b (diff)
downloaddrakx-ec7b4cc292c32a50422f4af83041c6cc0e6f0613.tar
drakx-ec7b4cc292c32a50422f4af83041c6cc0e6f0613.tar.gz
drakx-ec7b4cc292c32a50422f4af83041c6cc0e6f0613.tar.bz2
drakx-ec7b4cc292c32a50422f4af83041c6cc0e6f0613.tar.xz
drakx-ec7b4cc292c32a50422f4af83041c6cc0e6f0613.zip
(is_running) factorize code between mdkapplet & net_applet so that draksnapshot-applet can reuse it too
note that this code need to be adapted for multiples simultaneous sessions (being the same user or different users)
Diffstat (limited to 'perl-install/common.pm')
-rw-r--r--perl-install/common.pm11
1 files changed, 10 insertions, 1 deletions
diff --git a/perl-install/common.pm b/perl-install/common.pm
index 9ffb01ea1..2924c4cb7 100644
--- a/perl-install/common.pm
+++ b/perl-install/common.pm
@@ -10,7 +10,7 @@ use run_program;
use Exporter;
our @ISA = qw(Exporter);
-our @EXPORT = qw($SECTORSIZE N P N_ check_for_xserver files_exist formatTime MB formatXiB get_parent_uid makedev mandrake_release mandrake_release_info removeXiBSuffix require_root_capability setVirtual set_alternative set_l10n_sort set_permissions to_utf8 translate unmakedev);
+our @EXPORT = qw($SECTORSIZE N P N_ check_for_xserver files_exist formatTime MB formatXiB get_parent_uid is_running makedev mandrake_release mandrake_release_info removeXiBSuffix require_root_capability setVirtual set_alternative set_l10n_sort set_permissions to_utf8 translate unmakedev);
# perl_checker: RE-EXPORT-ALL
push @EXPORT, @MDK::Common::EXPORT;
@@ -300,6 +300,15 @@ sub set_permissions {
chmod(oct($perms), $file) or die "chmod of file $file failed: $!\n";
}
+sub is_running {
+ my ($name, $o_user) = @_;
+ my $user = $o_user || $ENV{USER};
+ any {
+ my ($ppid, $pid, $n) = /^\s*(\d+)\s+(\d+)\s+(.*)/;
+ $ppid != 1 && $pid != $$ && $n eq $name;
+ } `ps -o '%P %p %c' -u $user`;
+}
+
sub parse_release_file {
my ($prefix, $f, $part) = @_;
chomp(my $s = cat_("$prefix$f"));