[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[lintian] 01/04: L::C::Simple: Drop unused background sub



This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository lintian.

commit 761c8905b48199cc37022fa4d5790a276746998e
Author: Niels Thykier <niels@thykier.net>
Date:   Thu Apr 20 09:23:53 2017 +0000

    L::C::Simple: Drop unused background sub
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 lib/Lintian/Command/Simple.pm                      | 40 ++--------------
 t/scripts/Lintian/Command/Simple/02-background.t   | 14 ------
 .../Lintian/Command/Simple/03-multiple-jobs.t      | 54 ----------------------
 .../Lintian/Command/Simple/04-kill-multiple-jobs.t | 20 --------
 4 files changed, 3 insertions(+), 125 deletions(-)

diff --git a/lib/Lintian/Command/Simple.pm b/lib/Lintian/Command/Simple.pm
index bdeb45b..2d7f2cd 100644
--- a/lib/Lintian/Command/Simple.pm
+++ b/lib/Lintian/Command/Simple.pm
@@ -24,7 +24,7 @@ use POSIX qw(:sys_wait_h);
 
 use Lintian::Util qw(do_fork);
 
-our @EXPORT_OK = qw(rundir background wait_any kill_all);
+our @EXPORT_OK = qw(rundir wait_any kill_all);
 
 =head1 NAME
 
@@ -32,14 +32,9 @@ Lintian::Command::Simple - Run commands without pipes
 
 =head1 SYNOPSIS
 
-    use Lintian::Command::Simple qw(background rundir);
-
-    Lintian::Command::Simple::rundir ('./some-dir/', 'echo', 'hello world');
-
-    # Start a command in the background:
-    Lintian::Command::Simple::background('sleep', 10);
-    print wait() > 0 ? 'success' : 'failure';
+    use Lintian::Command::Simple qw(rundir);
 
+    rundir('./some-dir/', 'echo', 'hello world');
 
 =head1 DESCRIPTION
 
@@ -87,35 +82,6 @@ sub rundir {
     return $res;
 }
 
-=item background(command, argument  [, ...])
-
-Executes the given C<command> with the given arguments asynchronously
-and returns the process id of the child process.
-
-A return value of -1 indicates an error. This can either be a problem
-when calling CORE::fork() or when trying to run another command before
-calling wait() to reap the previous command.
-
-=cut
-
-sub background {
-    my $pid = do_fork();
-
-    if (not defined($pid)) {
-        # failed
-        return -1;
-    } elsif ($pid > 0) {
-        # parent
-        return $pid;
-    } else {
-        # child
-        close(STDIN);
-        open(STDIN, '<', '/dev/null');
-
-        CORE::exec @_ or die("Failed to exec '$_[0]': $!\n");
-    }
-}
-
 =item wait_any (hashref[, nohang])
 
 When starting multiple processes asynchronously, it is common to wait
diff --git a/t/scripts/Lintian/Command/Simple/02-background.t b/t/scripts/Lintian/Command/Simple/02-background.t
deleted file mode 100755
index 87b6e08..0000000
--- a/t/scripts/Lintian/Command/Simple/02-background.t
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-use Test::More tests => 3;
-
-use Lintian::Command::Simple qw(background);
-
-my $pid = background('true');
-cmp_ok($pid, '>', 0, 'Basic background (true)');
-
-is(waitpid($pid, 0), $pid, 'Waiting for pid');
-is($?, 0, 'Return status is 0');
-
diff --git a/t/scripts/Lintian/Command/Simple/03-multiple-jobs.t b/t/scripts/Lintian/Command/Simple/03-multiple-jobs.t
deleted file mode 100755
index be4887c..0000000
--- a/t/scripts/Lintian/Command/Simple/03-multiple-jobs.t
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-use Test::More tests => 22;
-
-use Lintian::Command::Simple qw(background wait_any);
-
-my $c = 4;
-my %jobs;
-
-while ($c) {
-    my $pid = background('sleep', 1);
-    $jobs{$pid} = 'value';
-    $c--;
-}
-
-while (my $value = wait_any(\%jobs)) {
-    is($?, 0, 'One job terminated successfully');
-    is($value, 'value', 'wait_any returned the value');
-    $c++;
-}
-
-is($c, 4, '4 jobs were started, 4 reaped');
-
-# again, but in list context
-
-while ($c) {
-    my $pid = background('sleep', 1);
-    $jobs{$pid} = "value $pid";
-    $c--;
-}
-
-while (my ($pid, $value) = wait_any(\%jobs)) {
-    is($?, 0, "Pid $pid terminated successfully");
-    is($value, "value $pid", 'wait_any returned the right value');
-    $c++;
-}
-
-is($c, 4, '4 more jobs were started, 4 reaped');
-
-# Make sure the case of an empty hash is handled properly
-# (i.e. undef is returned and no process is reaped)
-
-%jobs = ();
-my $pid = background('true');
-is(wait_any(\%jobs), undef, 'With an empty hash ref, wait() returns undef');
-
-is(my @list = wait_any(\%jobs),
-    0,'With an empty hash ref, in list context wait() returns null');
-
-is(waitpid($pid, 0), $pid, 'Reap successful');
-is($?, 0, 'Child returned successfully');
-
diff --git a/t/scripts/Lintian/Command/Simple/04-kill-multiple-jobs.t b/t/scripts/Lintian/Command/Simple/04-kill-multiple-jobs.t
deleted file mode 100755
index 9820c50..0000000
--- a/t/scripts/Lintian/Command/Simple/04-kill-multiple-jobs.t
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-use Test::More tests => 2;
-
-use Lintian::Command::Simple qw(background kill_all wait_any);
-
-my $c = 4;
-my %jobs;
-
-while ($c) {
-    my $pid = background('sleep', 10);
-    $jobs{$pid} = $1;
-    $c--;
-}
-
-is(kill_all(\%jobs), 4, '4 jobs were killed');
-
-is(wait_any(\%jobs), undef, 'kill(hashref) kills and reaps');

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: