[buildd-tools-devel] Bug#607844: weird interaction between setsid and SIGTSTP

Kees Cook kees at debian.org
Wed Dec 22 22:17:45 UTC 2010


Package: sbuild
Version: 0.60.5-1
Severity: normal
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu natty

While trying to build "upstart" in Ubuntu using the latest sbuild, one of
the unit tests failed. This was reduced to a test of "raise(SIGTSTP)",
which wasn't actually stopping the process. In tracking this down, I
isolated it as far as setting SETSID to 1 during the Sbuild::Build phase.

Attached is "wstopped.c" and "sbuild-poc" which tries to isolate the
problem. With SETSID=0, I get the expected behavior; the process waits for
SIGCONT:

# perl /tmp/sbuild-poc /tmp/wstopped 0
ok

With SETSID=1 (last cmdline option), the process does not wait for SIGCONT:

# perl /tmp/sbuild-poc /tmp/wstopped 1
waitid: No child processes

The bulk of wstopped.c is the creation of IPC pipes to make sure the child
has started and the parent can wait on it.

Very weird. Do you have any idea what is going on here?

Thanks!

-Kees

-- 
Kees Cook                                            @debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wstopped.c
Type: text/x-csrc
Size: 976 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/buildd-tools-devel/attachments/20101222/f6fd9632/attachment.c>
-------------- next part --------------
#!/usr/bin/perl
# Author: Kees Cook <kees at ubuntu.com>
#
# This shows a strange failure with raise(SIGTSTP) when SETSID=1 during
# an sbuild run.

# Build up a package similar to Sbuild::Build
package Test::Build;
use strict;
use warnings;
use Sbuild::Base;
use Sbuild::ChrootRoot;
use Sbuild::Conf;
use Sbuild::Utility;

BEGIN {
    use Exporter ();
    our (@ISA, @EXPORT);

    @ISA = qw(Exporter Sbuild::Base);

    @EXPORT = qw();
}

sub new {
    my $class = shift;

    my $conf = Sbuild::Conf->new();

    my $self = $class->SUPER::new($conf);
    bless($self, $class);

    return $self;
}

sub build {
    my $self = shift;
    my $cmd = shift;
    my $setsid = shift;
    $setsid += 0;

	my $session = Sbuild::ChrootRoot->new($self->get('Config'));

    $session->begin_session();
    $self->set('Session', $session);

    my $buildenv = {};
    $buildenv->{'PATH'} = '/bin:/usr/bin';

    my $command = {
        COMMAND => [$cmd],
        ENV => $buildenv,
        SETSID => $setsid,
        CHROOT => 1,
        PRIORITY => 0,
        DIR => '/tmp'
    };

    my $pipe = $self->get('Session')->pipe_command($command);

    while(<$pipe>) {
        $self->log($_);
    }
    close($pipe);
}

package main;

my $test = Test::Build->new();
$test->build($ARGV[0], $ARGV[1]);


More information about the Buildd-tools-devel mailing list