proot
proot copied to clipboard
Daemons aren't moved into the background correctly.
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.
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;
}
}
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.