proot icon indicating copy to clipboard operation
proot copied to clipboard

Daemons aren't moved into the background correctly.

Open cedric-vincent opened this issue 11 years ago • 2 comments

From issue #8:

As of my understanding, the issue with dtach under proot is due to the fact that proot waits (for ptrace events) in the foreground, even if all of its tracees were moved to the background. The problem is reproducible with the code below: under proot, the terminal control is never passed back to the parent shell, as it ought to be. In this regard, proot is not transparent.

int main()
{
    daemon(0, 0);
    while (1)
        sleep(1);
    return 0;
}

Note: strace -f suffers the same issue.

cedric-vincent avatar Apr 11 '13 08:04 cedric-vincent

New test-case, simplified from syscall point-of-view:

#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>

int main()
{
    int status;
    pid_t pid, sid;
    int fd;

    pid = fork();
    switch (pid) {
    case -1:
        return -1;

    case 0: /* child. */
        sid = setsid();
        if (sid == (pid_t) -1) {
            perror("sid");
            return 1;
        }

        while (1)
            sleep(1);

    default: /* parent. */
        return 0;
    }
}

cedric-vincent avatar Jun 21 '13 13:06 cedric-vincent

This has come up again as mobile-shell/mosh/issues/814. proot could handle this by forking itself differently. The child would daemonize itself then run proot's main code, and the parent would only do setup and then exec the chrooted user process.

cgull avatar Oct 25 '16 22:10 cgull