bug-autoconf
[Top][All Lists]
Advanced

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

autotest test suites stall when not a session leader


From: Julio Merino
Subject: autotest test suites stall when not a session leader
Date: Tue, 16 Aug 2011 10:55:48 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0) Gecko/20110624 Thunderbird/5.0

Hello,

I have an autotest-based test suite (let's call it the "testsuite") that I am running through a wrapper program. This wrapper program forks and creates a new process group for the testsuite to be run under. This new process group is NOT set to be the session leader.

The issue that I encounter is that the testsuite hangs during execution. The reason is that the testsuite is unconditionally doing "set -m" and this stalls if the shell is not a session leader because it awaits to become one.

The offending code from autoconf 2.68 is this:

-----
dnl Do we have job control?
if (set -m && set +m && set +b) >/dev/null 2>&1; then
  set +b
  at_job_control_on='set -m' at_job_control_off='set +m' at_job_group=-
else
  at_job_control_on=: at_job_control_off=: at_job_group=
fi
-----

I have simplified the whole thing to the test program below. Run the program giving the name of the shell as its first argument. If you run the program below with bash, it will appear to work. However, many other shells (tried Debian's dash and NetBSD's sh/ksh) expose the problem I am encountering. (And note that, both for Debian and NetBSD, the default /bin/sh shells is NOT bash, so I hit this problem all the time.)

-----
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <unistd.h>

int
main(int argc, char *const *argv)
{
        char *const shell = argv[1];

        pid_t pid = fork();
        if (pid == 0) {
                setpgid(0, getpid());
                char *const argv[] = {shell, "-m", "-c",
                                      "echo done", NULL};
                execv(shell, argv);
        } else {
                int status;
                waitpid(pid, &status, 0);
        }

        return 0;
}
-----

The blind call to "set -m" has to be avoided. I'm not sure what the right solution is, but at the very least I'd like to have a flag to the testsuite to explicitly enable/disable job control and thus skip the whole code snippet above. (Or maybe skip this when not running in parallel mode?)

Could you provide a fix please?

Thank you.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]