From: Zhang Qiang Date: Mon, 28 Jan 2013 19:44:42 +0000 (-0500) Subject: use sysconf() to get the number of processors X-Git-Tag: 0.4~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7e4d20ea276e3898f02976f11e17c3fe1f164214;p=tools%2Fdepanneur.git use sysconf() to get the number of processors * use sysconf() to get the number of processors * set jobs as $nprocessors * 2 Change-Id: Ib83100435f8a160400586f9a993fe46f22ad81dc --- diff --git a/depanneur b/depanneur index e69e34f..5132e1f 100755 --- a/depanneur +++ b/depanneur @@ -24,6 +24,7 @@ use URI; use POSIX ":sys_wait_h"; use File::Glob ':glob'; use User::pwent qw(getpw); +use POSIX qw(sysconf); # Global vars @@ -64,7 +65,7 @@ use File::Basename; # "sudo -v" period use constant SUDOV_PERIOD => 3*60; - +use constant SC_NPROCESSORS_ONLN => 84; my @threads; my @exclude = (); my @repos= (); @@ -1092,9 +1093,13 @@ sub build_package { push @args, "--use-system-qemu"; } push @args, "--uid $zuid:$zgid"; - my $nprocessors = int(`getconf _NPROCESSORS_ONLN`); - $nprocessors = 4 if ($nprocessors < 4); - push @args, "--jobs $nprocessors"; + my $nprocessors = 2; + if ($^O eq "linux") { + $nprocessors = int(sysconf(SC_NPROCESSORS_ONLN)); + } else { + warning("depanneur only support linux platform"); + } + push @args, "--jobs " . $nprocessors * 2; push @args, "--no-init" if ($noinit == 1); push @args, "--keep-packs" if ($keep_packs == 1); push @args, "--cachedir $cache_dir";